LanguageSelectorDropdown constructor
LanguageSelectorDropdown({
- Key? key,
- required List<
Locale> supportedLocales, - LanguageChangeHandler? languageChangeHandler,
- Icon? icon,
- LanguagesDisplayLanguage languagesDisplayLanguage = LanguagesDisplayLanguage.native,
- ProviderL10n? provider,
Implementation
LanguageSelectorDropdown({
super.key,
/// Provided the [AppLocalizations.supportedLocales]
required this.supportedLocales,
/// A callback to be called when the user selects a language.
this.languageChangeHandler,
/// If provided it will be used, else a [Icons.translate] will be used instead.
this.icon,
this.languagesDisplayLanguage = LanguagesDisplayLanguage.native,
/// If a [ProviderL10n] is provided, the locale of it will be changed according to the language chosen
this.provider,
}) {
var supportedLocalesTags = supportedLocales.map((e) => e.toLanguageTag());
final Map<String, Map<String, String>> localesListUnsorted = {};
languagesNames.keys
.where((e) => supportedLocalesTags.contains(e))
.forEach((supportedLanguageKey) {
localesList[supportedLanguageKey] = languagesNames[supportedLanguageKey]!;
});
localesListUnsorted.keys.toList()
..sort()
..forEach((key) {
localesList[key] = localesListUnsorted[key]!;
});
}