I have a statefull widged where a button has
onPressed: _exportData,
where _exportData defined this way
Future<void> _exportData() async {
...
setState(() {
_message = 'A message'; // I want to use localization string here
});
}
I need to pass localization string into the above setState() and I do it this way
Lang.key(ctx, 'about')
i.e. I need to pass the context there, but when I try to make it like this
onPressed: _exportData(ctx), // the error here
and
Future<void> _exportData(BuildContext ctx) async {...
there is an error on onPressed
The argument Future can not be assigned to the parameter type 'void Function()'
How cat I pass context inside _exportData or how can I use localization string from inside the _exportData?
update: actualy there was no need to pass context into _exportData, because context is awailable inside state class