populateLocales method

void populateLocales()

Populate maps for locales at startup to optimise performance.

Implementation

void populateLocales() async {
  /// A list of locales that the app will support at runtime. This is not
  /// related to supported target languages.
  final List<Locale> availableLocales = List<Locale>.unmodifiable(
    [
      const Locale('en', 'US'),
    ],
  );

  locales = Map<String, Locale>.unmodifiable(
    Map<String, Locale>.fromEntries(
      availableLocales.map(
        (locale) => MapEntry(locale.toLanguageTag(), locale),
      ),
    ),
  );
}