refreshLocale static method
void
refreshLocale()
Shows NyLocalization's current locale without restarting the app.
The page, its state and the navigation stack stay as they are: every widget builds again, so translated text, Material's own strings and the text direction follow the new locale. Text a page worked out once and kept in its state stays as it was.
Implementation
static void refreshLocale() {
_NyAppState._active?._localeNotifier.value = NyLocalization.instance.locale;
void rebuild(Element element) {
element.markNeedsBuild();
element.visitChildren(rebuild);
}
WidgetsBinding.instance.rootElement?.visitChildren(rebuild);
}