version bump

This commit is contained in:
Salvatore Giordano
2020-04-04 16:41:37 +02:00
parent a01ce10810
commit 47a3336058
4 changed files with 19 additions and 17 deletions

View File

@@ -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 ## 1.3.7
- Add `customList` property - Add `customList` property

View File

@@ -38,7 +38,7 @@ class _MyAppState extends State<MyApp> {
initialSelection: 'IT', initialSelection: 'IT',
favorite: ['+39', 'FR'], favorite: ['+39', 'FR'],
showFlag: false, showFlag: false,
customList: ['IT', 'FR'], countryFilter: ['IT', 'FR'],
showFlagDialog: true, showFlagDialog: true,
comparator: (a, b) => b.name.compareTo(a.name), comparator: (a, b) => b.name.compareTo(a.name),
//Get the country information relevant to the initial selection //Get the country information relevant to the initial selection

View File

@@ -26,7 +26,7 @@ class CountryCodePicker extends StatefulWidget {
final Size dialogSize; final Size dialogSize;
/// used to customize the country list /// used to customize the country list
final List<String> customList; final List<String> countryFilter;
/// shows the name of the country instead of the dialcode /// shows the name of the country instead of the dialcode
final bool showOnlyCountryWhenClosed; final bool showOnlyCountryWhenClosed;
@@ -45,9 +45,6 @@ class CountryCodePicker extends StatefulWidget {
final bool showFlagDialog; final bool showFlagDialog;
/// contains the country codes to load only the specified countries.
final List<String> countryFilter;
/// Width of the flag images /// Width of the flag images
final double flagWidth; final double flagWidth;
@@ -59,7 +56,6 @@ class CountryCodePicker extends StatefulWidget {
this.onInit, this.onInit,
this.initialSelection, this.initialSelection,
this.favorite = const [], this.favorite = const [],
this.countryFilter = const [],
this.textStyle, this.textStyle,
this.padding = const EdgeInsets.all(0.0), this.padding = const EdgeInsets.all(0.0),
this.showCountryOnly = false, this.showCountryOnly = false,
@@ -76,7 +72,7 @@ class CountryCodePicker extends StatefulWidget {
this.enabled = true, this.enabled = true,
this.textOverflow = TextOverflow.ellipsis, this.textOverflow = TextOverflow.ellipsis,
this.comparator, this.comparator,
this.customList, this.countryFilter,
this.dialogSize, this.dialogSize,
Key key, Key key,
}) : super(key: key); }) : super(key: key);
@@ -92,19 +88,17 @@ class CountryCodePicker extends StatefulWidget {
elements.sort(comparator); elements.sort(comparator);
} }
if (customList != null) { if (countryFilter != null && countryFilter.isNotEmpty) {
final uppercaseCustomList =
countryFilter.map((c) => c.toUpperCase()).toList();
elements = elements elements = elements
.where((c) => .where((c) =>
customList.contains(c.code) || uppercaseCustomList.contains(c.code) ||
customList.contains(c.name) || uppercaseCustomList.contains(c.name) ||
customList.contains(c.dialCode)) uppercaseCustomList.contains(c.dialCode))
.toList(); .toList();
} }
if (countryFilter.length > 0) {
elements = elements.where((c) => countryFilter.contains(c.code)).toList();
}
return CountryCodePickerState(elements); return CountryCodePickerState(elements);
} }
} }
@@ -186,7 +180,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
} }
@override @override
initState() { void initState() {
if (widget.initialSelection != null) { if (widget.initialSelection != null) {
selectedItem = elements.firstWhere( selectedItem = elements.firstWhere(
(e) => (e) =>

View File

@@ -1,6 +1,6 @@
name: country_code_picker 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 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 homepage: https://github.com/imtoori/CountryCodePicker
environment: environment: