From 9af6647f1a6cab2a9586fac218613357656b03c7 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Sun, 8 Mar 2020 23:57:03 +0100 Subject: [PATCH] update version --- CHANGELOG.md | 4 ++++ example/lib/main.dart | 2 ++ lib/country_code_picker.dart | 16 +++++++++++----- pubspec.yaml | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fb070a..165da55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.4 + +- Add `showFlagDialog` and `showFlagMain` + ## 1.3.3 - Fix a bug in localization diff --git a/example/lib/main.dart b/example/lib/main.dart index fd3aa67..791615f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -42,6 +42,8 @@ class _MyAppState extends State { // Initial selection and favorite can be one of code ('IT') OR dial_code('+39') initialSelection: 'IT', favorite: ['+39', 'FR'], + showFlag: false, + showFlagDialog: true, //Get the country information relevant to the initial selection onInit: (code) => print("${code.name} ${code.dialCode}"), ), diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index d2b422c..2eee8f5 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -35,6 +35,10 @@ class CountryCodePicker extends StatefulWidget { /// shows the flag final bool showFlag; + final bool showFlagMain; + + final bool showFlagDialog; + /// contains the country codes to load only the specified countries. final List countryFilter; @@ -56,6 +60,8 @@ class CountryCodePicker extends StatefulWidget { this.showOnlyCountryWhenClosed = false, this.alignLeft = false, this.showFlag = true, + this.showFlagDialog, + this.showFlagMain, this.builder, this.flagWidth = 32.0, this.enabled = true, @@ -100,7 +106,7 @@ class _CountryCodePickerState extends State { direction: Axis.horizontal, mainAxisSize: MainAxisSize.min, children: [ - if (widget.showFlag) + if (widget.showFlag || (widget.showFlagMain == true)) Flexible( flex: widget.alignLeft ? 0 : 1, fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, @@ -135,6 +141,9 @@ class _CountryCodePickerState extends State { @override void didUpdateWidget(CountryCodePicker oldWidget) { super.didUpdateWidget(oldWidget); + + _onInit(selectedItem); + if (oldWidget.initialSelection != widget.initialSelection) { if (widget.initialSelection != null) { selectedItem = elements.firstWhere( @@ -161,9 +170,6 @@ class _CountryCodePickerState extends State { selectedItem = elements[0]; } - //Change added: get the initial entered country information - _onInit(selectedItem); - favoriteElements = elements .where((e) => widget.favorite.firstWhere( @@ -184,7 +190,7 @@ class _CountryCodePickerState extends State { emptySearchBuilder: widget.emptySearchBuilder, searchDecoration: widget.searchDecoration, searchStyle: widget.searchStyle, - showFlag: widget.showFlag, + showFlag: widget.showFlag || (widget.showFlagDialog == true), flagWidth: widget.flagWidth, ), ).then((e) { diff --git a/pubspec.yaml b/pubspec.yaml index 3f04066..fa47aaf 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. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox -version: 1.3.3 +version: 1.3.4 homepage: https://github.com/Salvatore-Giordano/CountryCodePicker environment: