hasSelectableCountryForCustomDocument method
bool
hasSelectableCountryForCustomDocument(
- Map<String, dynamic>? document
)
Implementation
bool hasSelectableCountryForCustomDocument(Map<String, dynamic>? document) {
final countries = document?['countries'];
if (countries is! List) {
return false;
}
for (final group in countries) {
if (group is! Map<String, dynamic>) {
continue;
}
final groupValue =
(group['value'] as String?)?.trim().toLowerCase() ?? '';
if (groupValue.isNotEmpty && groupValue != 'world') {
return true;
}
final nestedCountries = group['countries'];
if (nestedCountries is! List) {
continue;
}
for (final country in nestedCountries) {
if (country is! Map<String, dynamic>) {
continue;
}
final countryValue =
(country['value'] as String?)?.trim().toLowerCase() ?? '';
if (countryValue.isNotEmpty && countryValue != 'world') {
return true;
}
}
}
return false;
}