add readme
This commit is contained in:
20
README.md
20
README.md
@@ -4,4 +4,22 @@ A flutter package for showing a country code selector.
|
|||||||
|
|
||||||
## Usage
|
## 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
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
selectedItem = elements.firstWhere((e) => e.code == widget.initialSelection,
|
if (widget.initialSelection != null) {
|
||||||
orElse: () => elements[0]);
|
selectedItem = elements.firstWhere(
|
||||||
|
(e) => e.code.toUpperCase() == widget.initialSelection.toUpperCase(),
|
||||||
|
orElse: () => elements[0]);
|
||||||
|
}else{
|
||||||
|
selectedItem = elements[0];
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user