diff --git a/lib/pangea/widgets/user_settings/p_language_dropdown.dart b/lib/pangea/widgets/user_settings/p_language_dropdown.dart index e9a02bb336..0793efdc22 100644 --- a/lib/pangea/widgets/user_settings/p_language_dropdown.dart +++ b/lib/pangea/widgets/user_settings/p_language_dropdown.dart @@ -28,15 +28,18 @@ class _PLanguageDropdownState extends State { Widget build(BuildContext context) { final List sortedLanguages = widget.languages; final String systemLang = Localizations.localeOf(context).languageCode; + final List languagePriority = [systemLang, 'en', 'es']; int sortLanguages(LanguageModel a, LanguageModel b) { final String aLang = a.langCode; final String bLang = b.langCode; if (aLang == bLang) return 0; - final List languagePriority = [systemLang, 'en', 'es']; final bool aIsPriority = languagePriority.contains(a.langCode); final bool bIsPriority = languagePriority.contains(b.langCode); + if (!aIsPriority && !bIsPriority) { + return a.getDisplayName(context)!.compareTo(b.getDisplayName(context)!); + } if (aIsPriority && bIsPriority) { final int aPriority = languagePriority.indexOf(a.langCode); @@ -44,10 +47,7 @@ class _PLanguageDropdownState extends State { return aPriority - bPriority; } - if (aIsPriority) return -1; - if (bIsPriority) return 1; - - return a.getDisplayName(context)!.compareTo(b.getDisplayName(context)!); + return aIsPriority ? -1 : 1; } sortedLanguages.sort((a, b) => sortLanguages(a, b));