changeLocale function

Future changeLocale(
  1. BuildContext context,
  2. String? localeCode
)

Change the currently selected locale

Implementation

Future changeLocale(BuildContext context, String? localeCode) async {
  if (localeCode != null) {
    await LocalizedApp.of(context)
        .delegate
        .changeLocale(localeFromString(localeCode));

    LocalizationProvider.of(context).state.onLocaleChanged();
  }
}