The generated AppLocalizations in flutter has many getters
final appLocalizations = AppLocalizations.of(context)!;
print(appLocalizations.helloWorld);
I have a use case that the getter keys is stored in a List<String> and I need to translate them
const key = 'helloWorld';
print(appLocalizations[key]);
How I can access to the getter by a String variable like key ?
Unfortunately you can't do that as of yet. I've filed a feature request a while back, but they don't seem enthused about it.
You can follow up on it here: https://github.com/flutter/flutter/issues/84326
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With