0

When I am using AppLocalizations.of(context)!.value in ternary operation in flutter , then it show error "Null check operator used on a null value".

Here is an example of usage that makes error:

isLoading ? AppLocalizations.of(context)!.loading : AppLocalizations.of(context)!.value

In this code show error Null check operator used on a null value

isLoading ? Text(AppLocalizations.of(context)!.orderIsBeingSending) : Text("${AppLocalizations.of(context)!.orderId} : ${orderSummary.orderResponse?.no.toString()}");

Debug output: Debug output

Ivo
  • 18,659
  • 2
  • 23
  • 35
Sujith S
  • 21
  • 5
  • Duplicate of https://stackoverflow.com/questions/65657443/best-approach-to-null-safe-applocalization-strings – Texv Nov 07 '22 at 08:40
  • 1
    Please try to make your uestion more readable. Espacially your code highlighting. See this post to learn the basics of posting your code to StackOverflow: https://meta.stackexchange.com/a/22189/407041 – Marcel Hofgesang Nov 07 '22 at 08:45

1 Answers1

0

add this line in l10n.yaml:

nullable-getter: false
Sparko Sol
  • 651
  • 1
  • 9