v0.1.3: Favorite can be one of code or dial code
This commit is contained in:
@@ -13,3 +13,7 @@ Removed flags in iOS because they show up weirdly.
|
|||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
Tested with dart 2
|
Tested with dart 2
|
||||||
|
|
||||||
|
## 0.1.2
|
||||||
|
|
||||||
|
Favorite and initial selection can be one of code or dial code
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[](https://pub.dartlang.org/packages/country_code_picker)
|
[](https://pub.dartlang.org/packages/country_code_picker)
|
||||||
|
|
||||||
# country_code_picker
|
# country_code_picker
|
||||||
|
|
||||||
@@ -19,9 +19,9 @@ Just put the component in your application setting the onChanged callback.
|
|||||||
body: new Center(
|
body: new Center(
|
||||||
child: new CountryCodePicker(
|
child: new CountryCodePicker(
|
||||||
onChanged: print,
|
onChanged: print,
|
||||||
// Initial selection can be one of code ('IT') OR dial_code('+39')
|
// Initial selection and favorite can be one of code ('IT') OR dial_code('+39')
|
||||||
initialSelection: 'IT',
|
initialSelection: 'IT',
|
||||||
favorite: ['IT','FR'],
|
favorite: ['+39','FR'],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -44,19 +44,18 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
if (widget.initialSelection != null) {
|
if (widget.initialSelection != null) {
|
||||||
selectedItem = elements.firstWhere(
|
selectedItem = elements.firstWhere((e) {
|
||||||
(e) {
|
e.code.toUpperCase() == widget.initialSelection.toUpperCase() ||
|
||||||
e.code.toUpperCase() == widget.initialSelection.toUpperCase() ||
|
e.dialCode == widget.initialSelection.toString();
|
||||||
e.dialCode == widget.initialSelection.toString();
|
}, orElse: () => elements[0]);
|
||||||
},
|
|
||||||
orElse: () => elements[0]);
|
|
||||||
} else {
|
} else {
|
||||||
selectedItem = elements[0];
|
selectedItem = elements[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
favoriteElements = elements
|
favoriteElements = elements
|
||||||
.where((e) =>
|
.where((e) =>
|
||||||
widget.favorite.firstWhere((f) => e.code == f.toUpperCase(),
|
widget.favorite.firstWhere(
|
||||||
|
(f) => e.code == f.toUpperCase() || e.dialCode == f.toString(),
|
||||||
orElse: () => null) !=
|
orElse: () => null) !=
|
||||||
null)
|
null)
|
||||||
.toList();
|
.toList();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: country_code_picker
|
name: country_code_picker
|
||||||
description: A flutter package for showing a country code selector.
|
description: A flutter package for showing a country code selector.
|
||||||
version: 0.1.1
|
version: 0.1.2
|
||||||
author: Salvatore-Giordano <salvatoregiordanoo@gmail.com>
|
author: Salvatore-Giordano <salvatoregiordanoo@gmail.com>
|
||||||
homepage: https://github.com/Salvatore-Giordano/CountryCodePicker
|
homepage: https://github.com/Salvatore-Giordano/CountryCodePicker
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user