getLocaleOptions method

List<LocaleOption> getLocaleOptions()

Implementation

List<LocaleOption> getLocaleOptions() {
  var currentLocale = getCurrentLocale();
  var currentLocaleShort = Intl.shortLocale(currentLocale);

  var initializedLocales = getInitializedLocales();
  var currentLocaleInitialized = initializedLocales.contains(currentLocale);

  var options = <LocaleOption>[];

  for (var l in initializedLocales) {
    var localeName = getLocaleName(l,
        defaultName: l,
        nativeName: true,
        nativeLocale: '*',
        preserveLatinNames: true);
    var sel = (l == currentLocale) ||
        (!currentLocaleInitialized && l == currentLocaleShort);

    var opt = LocaleOption(l, sel, localeName);
    options.add(opt);
  }

  return options;
}