When working with Android (Kotlin) there are many strings that are used many times, I package them in a library (carefully translated into many different languages).
When I need to use it, just add that library and use is very easy.
With Flutter how can I do that?
2
Answers
You can create a package for translations with
flutter create -t package [package_name]
and store translated strings there.The package can be imported via path or git repository, see the docs for details.
Also here is a great piece on implementing l10n in Flutter in a robust way.
check easy_localization package, it allows you to declare your translations in json files matching the languages you want like
en.json
,
it.json
…then it provides you with methods to show each string by its JSON key, like:
Which will show the appropriate value on the language which the app is configured to.