add readme
This commit is contained in:
18
README.md
18
README.md
@@ -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
|
||||
@@ -41,8 +41,13 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
|
||||
@override
|
||||
initState() {
|
||||
selectedItem = elements.firstWhere((e) => e.code == widget.initialSelection,
|
||||
if (widget.initialSelection != null) {
|
||||
selectedItem = elements.firstWhere(
|
||||
(e) => e.code.toUpperCase() == widget.initialSelection.toUpperCase(),
|
||||
orElse: () => elements[0]);
|
||||
}else{
|
||||
selectedItem = elements[0];
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user