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
|
||||
|
||||
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
|
||||
|
||||
@@ -19,9 +19,9 @@ Just put the component in your application setting the onChanged callback.
|
||||
body: new Center(
|
||||
child: new CountryCodePicker(
|
||||
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',
|
||||
favorite: ['IT','FR'],
|
||||
favorite: ['+39','FR'],
|
||||
),
|
||||
));
|
||||
|
||||
|
||||
@@ -44,19 +44,18 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
@override
|
||||
initState() {
|
||||
if (widget.initialSelection != null) {
|
||||
selectedItem = elements.firstWhere(
|
||||
(e) {
|
||||
e.code.toUpperCase() == widget.initialSelection.toUpperCase() ||
|
||||
e.dialCode == widget.initialSelection.toString();
|
||||
},
|
||||
orElse: () => elements[0]);
|
||||
selectedItem = elements.firstWhere((e) {
|
||||
e.code.toUpperCase() == widget.initialSelection.toUpperCase() ||
|
||||
e.dialCode == widget.initialSelection.toString();
|
||||
}, orElse: () => elements[0]);
|
||||
} else {
|
||||
selectedItem = elements[0];
|
||||
}
|
||||
|
||||
favoriteElements = elements
|
||||
.where((e) =>
|
||||
widget.favorite.firstWhere((f) => e.code == f.toUpperCase(),
|
||||
widget.favorite.firstWhere(
|
||||
(f) => e.code == f.toUpperCase() || e.dialCode == f.toString(),
|
||||
orElse: () => null) !=
|
||||
null)
|
||||
.toList();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: country_code_picker
|
||||
description: A flutter package for showing a country code selector.
|
||||
version: 0.1.1
|
||||
version: 0.1.2
|
||||
author: Salvatore-Giordano <salvatoregiordanoo@gmail.com>
|
||||
homepage: https://github.com/Salvatore-Giordano/CountryCodePicker
|
||||
|
||||
|
||||
Reference in New Issue
Block a user