diff --git a/flags/an.png b/flags/an.png deleted file mode 100644 index 6f5557f7..00000000 Binary files a/flags/an.png and /dev/null differ diff --git a/lib/country_code.dart b/lib/country_code.dart index 3d1a6b47..9fa23322 100644 --- a/lib/country_code.dart +++ b/lib/country_code.dart @@ -56,7 +56,7 @@ class CountryCode { factory CountryCode.fromJson(Map<String, dynamic> json) { return CountryCode( - name: json['name'], + name: json['name'] is List ? json['name'].first : json['name'], code: json['code'], dialCode: json['dial_code'], flagUri: 'flags/${json['code'].toLowerCase()}.png', @@ -68,11 +68,5 @@ class CountryCode { String toLongString() => "$dialCode ${toCountryStringOnly()}"; - String toCountryStringOnly() { - return '$_cleanName'; - } - - String? get _cleanName { - return name?.replaceAll(RegExp(r'[[\]]'), '').split(',').first; - } + String toCountryStringOnly() => name ?? ''; } diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index c979e12b..5d941523 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -49,6 +49,9 @@ class CountryCodePicker extends StatefulWidget { /// shows the name of the country instead of the dialcode final bool showOnlyCountryWhenClosed; + /// whether to show the dialog using the root navigator + final bool useRootNavigator; + /// aligns the flag and the Text left /// /// additionally this option also fills the available space of the widget. @@ -97,6 +100,7 @@ class CountryCodePicker extends StatefulWidget { this.dialogTextStyle, this.emptySearchBuilder, this.showOnlyCountryWhenClosed = false, + this.useRootNavigator = false, this.alignLeft = false, this.showFlag = true, this.showFlagDialog, @@ -327,6 +331,7 @@ class CountryCodePickerState extends State<CountryCodePicker> { showMaterialModalBottomSheet( barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5), backgroundColor: widget.backgroundColor ?? Colors.transparent, + useRootNavigator: widget.useRootNavigator, context: context, builder: (context) => Center( child: SelectionDialog( diff --git a/lib/country_codes.dart b/lib/country_codes.dart index 7e7c0823..eb6b1519 100644 --- a/lib/country_codes.dart +++ b/lib/country_codes.dart @@ -134,6 +134,11 @@ const List<Map<String, String>> codes = [ "code": "BO", "dial_code": "+591", }, + { + "name": "Bonaire, Saint Eustatius and Saba", + "code": "BQ", + "dial_code": "+599", + }, { "name": "Bosna i Hercegovina", "code": "BA", @@ -204,6 +209,11 @@ const List<Map<String, String>> codes = [ "code": "KY", "dial_code": "+1345", }, + { + "name": "Curaçao", + "code": "CW", + "dial_code": "+5999", + }, { "name": "Ködörösêse tî Bêafrîka", "code": "CF", @@ -779,11 +789,6 @@ const List<Map<String, String>> codes = [ "code": "NL", "dial_code": "+31", }, - { - "name": "Netherlands Antilles", - "code": "AN", - "dial_code": "+599", - }, { "name": "Nouvelle-Calédonie", "code": "NC", diff --git a/lib/country_localizations.dart b/lib/country_localizations.dart index 3020f78e..6d7ad7f9 100644 --- a/lib/country_localizations.dart +++ b/lib/country_localizations.dart @@ -26,7 +26,13 @@ class CountryLocalizations { Map<String, dynamic> jsonMap = json.decode(jsonString); _localizedStrings = jsonMap.map((key, value) { - return MapEntry(key, value.toString()); + if (value is String) { + return MapEntry(key, value); + } else if (value is List) { + return MapEntry(key, value.first.toString()); + } else { + return MapEntry(key, value.toString()); + } }); return true;