From a7e8a74c558af0fc1945b4bed8b63883f9e17090 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 5 Apr 2018 09:25:06 +0200 Subject: [PATCH] v0.1.3: Favorite can be one of code or dial code --- CHANGELOG.md | 4 ++++ README.md | 6 +++--- lib/country_code_picker.dart | 13 ++++++------- pubspec.yaml | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67d72d7..1541fce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index cb1d33c..0ee7be0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Pub](https://img.shields.io/badge/Pub-0.1.1-orange.svg)](https://pub.dartlang.org/packages/country_code_picker) +[![Pub](https://img.shields.io/badge/Pub-0.1.2-orange.svg)](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'], ), )); diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 6e48144..1c96fdd 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -44,19 +44,18 @@ class _CountryCodePickerState extends State { @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(); diff --git a/pubspec.yaml b/pubspec.yaml index a8efcd2..039c147 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 homepage: https://github.com/Salvatore-Giordano/CountryCodePicker