Tom
Tom

Reputation: 413

How to manually change Locale in flutter?

I'm kind of new to flutter development and I've hit a big wall with the issue of making the app "international".

For this project, it's supposed to be available in 3 languages including english. So I've followed the flutter tutorial available here. I wrote 3 .arb files, and everything works with the phone's language. Now I'm supposed to create a button in the settings page that allows me to manually switch language.

And that's where I'm stuck. I've found many tutorials from different pages, all different, none of them I was able to make work. I've defined globale Locales and I've tried to call AndroidLocalizationDelegate.load(myLocaleEN) to no avail.

Any help is appreciated, I'm really lost!

Upvotes: 2

Views: 1255

Answers (1)

Kirill Bubochkin
Kirill Bubochkin

Reputation: 6353

If you're using MaterialApp / CupertinoApp / WidgetsApp then you can just pass your current locale with the locale parameter.

So you can treat your locale as any other state in the app – change it on button press, store it in shared preferences, etc.

Upvotes: 3

Related Questions