I'm trying to use the intl plugin to get more translations of my app, but it always needs a context. In files without context where I simply have to assign a value to the variable what should I do?
For example I would like to do something like this::
String yes = "${AppLocalizations.of(context)!.yes}"
As other answers suggest you can put your
variableinsidebuild, however, if you don't want to do that then you can define aNavigator Keyand get the currentcontextfrom it anywhere in your code.Define Navigator Key:
Attach it to your
MaterialApp:Get current context from navigatorKey: