toLocale static method
Implementation
static Locale? toLocale(String? _locale) {
Locale? locale;
if (_locale != null && _locale.isNotEmpty) {
//
final localeCode = _locale.split('-');
String languageCode;
String? countryCode;
if (localeCode.length == 2) {
languageCode = localeCode.first;
countryCode = localeCode.last;
} else {
languageCode = localeCode.first;
}
locale = Locale(languageCode, countryCode);
}
return locale;
}