initDefaultLocale function

Future<void> initDefaultLocale([
  1. String? locale
])

Initializes Intl.defaultLocale for formatting dates, times, and numbers.

If locale is not specified, the system locale is used.

See also:

  • Intl.defaultLocale
  • Intl.systemLocale

Implementation

Future<void> initDefaultLocale([String? locale]) async {
  Intl.defaultLocale = locale ??
      await findSystemLocale()
          // Fallback to 'en' if the system locale is 'POSIX' or undefined.
          .then((l) => l == 'POSIX' || l == 'und' ? 'en' : l);
}