findLocaleName function
If there are items related to Platform.localeName
in supportedLocaleNames
, return this item,
otherwise return null
.
Implementation
String? findLocaleName(
Iterable<String> supportedLocaleNames, String localeName) {
if (supportedLocaleNames.contains(localeName)) {
return localeName;
}
var lns = localeName.split('_');
if (lns.length > 2) {
var n = '${lns[0]}_${lns[2]}';
if (supportedLocaleNames.contains(n)) {
return n;
}
}
if (supportedLocaleNames.contains(lns[0])) {
return lns[0];
}
return null;
}