getByName static method
Get country by name
May use withLowerCase
flag to compare each country name
with lower case letters
Implementation
static Country? getByName(
String name, {
bool withLowerCase = false,
}) {
bool handleWhere(Country country) {
return withLowerCase
? country.name.toLowerCase() == name
: country.name == name;
}
return toList().firstWhereOrNull(handleWhere);
}