getLocaleStream method
Gets the broadcast stream to keep track of every locale change.
It fires every time LocaleSettings.setLocale, LocaleSettings.setLocaleRaw, or LocaleSettings.useDeviceLocale is called.
To additionally listen to device locale changes, either call
(1) LocaleSettings.useDeviceLocale
(2) or set listenToDeviceLocale to true
.
Both will fire setLocale when device locale changes.
You need to wrap your app with TranslationProvider
.
Usage: LocaleSettings.getLocaleStream().listen((locale) { print('new locale: $locale'); });
Implementation
Stream<E> getLocaleStream() {
return GlobalLocaleState.instance.getStream().map((locale) {
return utils.parseAppLocale(locale);
});
}