changeLocale method

void changeLocale(
  1. BuildContext context,
  2. String? locale
)

Implementation

void changeLocale(BuildContext context, String? locale) async {
  if (locale?.isEmpty ?? true) return;
  var currentLocale = locales[locale!];
  // localeName = locale;
  if (currentLocale != null) {
    await context.setLocale(currentLocale);
  }
  if (hasListeners) notifyListeners();
}