diff --git a/CHANGELOG.md b/CHANGELOG.md index 319110d..1df6984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.3.8 + +- Expose state to let use a key to open the dialog + +- Add dialog size config + +- Remove customList and fix countryFilter + ## 1.3.7 - Add `customList` property diff --git a/example/lib/main.dart b/example/lib/main.dart index ad5a759..fe90dc3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -38,7 +38,7 @@ class _MyAppState extends State { initialSelection: 'IT', favorite: ['+39', 'FR'], showFlag: false, - customList: ['IT', 'FR'], + countryFilter: ['IT', 'FR'], showFlagDialog: true, comparator: (a, b) => b.name.compareTo(a.name), //Get the country information relevant to the initial selection diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index e522a69..42cd306 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -26,7 +26,7 @@ class CountryCodePicker extends StatefulWidget { final Size dialogSize; /// used to customize the country list - final List customList; + final List countryFilter; /// shows the name of the country instead of the dialcode final bool showOnlyCountryWhenClosed; @@ -45,9 +45,6 @@ class CountryCodePicker extends StatefulWidget { final bool showFlagDialog; - /// contains the country codes to load only the specified countries. - final List countryFilter; - /// Width of the flag images final double flagWidth; @@ -59,7 +56,6 @@ class CountryCodePicker extends StatefulWidget { this.onInit, this.initialSelection, this.favorite = const [], - this.countryFilter = const [], this.textStyle, this.padding = const EdgeInsets.all(0.0), this.showCountryOnly = false, @@ -76,7 +72,7 @@ class CountryCodePicker extends StatefulWidget { this.enabled = true, this.textOverflow = TextOverflow.ellipsis, this.comparator, - this.customList, + this.countryFilter, this.dialogSize, Key key, }) : super(key: key); @@ -92,19 +88,17 @@ class CountryCodePicker extends StatefulWidget { elements.sort(comparator); } - if (customList != null) { + if (countryFilter != null && countryFilter.isNotEmpty) { + final uppercaseCustomList = + countryFilter.map((c) => c.toUpperCase()).toList(); elements = elements .where((c) => - customList.contains(c.code) || - customList.contains(c.name) || - customList.contains(c.dialCode)) + uppercaseCustomList.contains(c.code) || + uppercaseCustomList.contains(c.name) || + uppercaseCustomList.contains(c.dialCode)) .toList(); } - if (countryFilter.length > 0) { - elements = elements.where((c) => countryFilter.contains(c.code)).toList(); - } - return CountryCodePickerState(elements); } } @@ -186,7 +180,7 @@ class CountryCodePickerState extends State { } @override - initState() { + void initState() { if (widget.initialSelection != null) { selectedItem = elements.firstWhere( (e) => diff --git a/pubspec.yaml b/pubspec.yaml index d44cccf..68990d3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: country_code_picker description: A flutter package for showing a country code selector. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox -version: 1.3.7 +version: 1.3.8 homepage: https://github.com/imtoori/CountryCodePicker environment: