add readme

This commit is contained in:
Salvatore Giordano
2018-04-01 01:11:59 +02:00
parent 2101639d78
commit 6ede12883a
2 changed files with 26 additions and 3 deletions

View File

@@ -4,4 +4,22 @@ A flutter package for showing a country code selector.
## Usage
Just put the component in your application setting the onChanged callback.
```dart
......
@override
Widget build(BuildContext context) => new Scaffold(
body: new Center(
child: new CountryCodePicker(
onChanged: print,
),
));
.....
```
It's also possible to select the initial selection using the country code.
## Known issues
- On iOS the icons are not showned

View File

@@ -41,8 +41,13 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
@override
initState() {
selectedItem = elements.firstWhere((e) => e.code == widget.initialSelection,
orElse: () => elements[0]);
if (widget.initialSelection != null) {
selectedItem = elements.firstWhere(
(e) => e.code.toUpperCase() == widget.initialSelection.toUpperCase(),
orElse: () => elements[0]);
}else{
selectedItem = elements[0];
}
super.initState();
}