Search code examples
flutter

How to get the list of Locales configured at the host operating system?


In Flutter, how do you get the list of Locales configured at the host operating system?

Platform.localeName only contains the current locale, but none of the additionally configured Locales.

One workaround would be to cache the value of parameter locales passed to LocaleListResolutionCallback, but that's pretty messy because it receives the system configured Locales only the very first time it gets called. Beside that, there's certainly a way to read it on demand.

Any advise is welcome, Thank you.


Solution

  • PlatformDispatcher.instance.locales; contains the list of the OS's configured locales. Here are the details.