From 6ede12883a05d3a2637a2ad4c00b658a87994819 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Sun, 1 Apr 2018 01:11:59 +0200 Subject: [PATCH] add readme --- README.md | 20 +++++++++++++++++++- lib/country_code_picker.dart | 9 +++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 47cf76d..91be9d5 100644 --- a/README.md +++ b/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 \ No newline at end of file diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 95b32c0..af0058c 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -41,8 +41,13 @@ class _CountryCodePickerState extends State { @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(); }