getLocale method

Future<Locale?> getLocale()

User-selected UI language. Returns null when unset, meaning "follow the device/OS locale" — the app then leaves MaterialApp.locale null and Flutter resolves against MaterialApp.supportedLocales. Only the language subtag is stored (e.g. 'fr'), which is all the app's supported locales distinguish.

Implementation

Future<Locale?> getLocale() async {
  final p = await _prefs();
  final code = p.getString(_localeKey);
  if (code == null || code.isEmpty) return null;
  return Locale(code);
}