Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Removed Netherlands Antilles, added BES & Curaçao #181

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed flags/an.png
Binary file not shown.
10 changes: 2 additions & 8 deletions lib/country_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 ?? '';
}
5 changes: 5 additions & 0 deletions lib/country_code_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
15 changes: 10 additions & 5 deletions lib/country_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion lib/country_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down