getCurrentLocale static method

Locale getCurrentLocale({
  1. BuildContext? context,
})

Get the current system locale

Implementation

static Locale getCurrentLocale({BuildContext? context}) {
  if (context != null) {
    // Preferred way - get locale from context
    return Localizations.localeOf(context);
  }

  // Fallback to platform dispatcher if context is not available
  return ui.PlatformDispatcher.instance.locale;
}