From c46aa1c40e6ab2abfe815777cd46983b644934b7 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Sat, 9 May 2020 12:25:30 +0200 Subject: [PATCH] fix showflagdialog and main to override the showflag property --- example/lib/main.dart | 8 +++----- lib/country_code_picker.dart | 8 ++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index a92be9c..d425bc4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -38,9 +38,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, countryFilter: ['IT', 'FR'], - showFlagDialog: true, + showFlagDialog: false, comparator: (a, b) => b.name.compareTo(a.name), //Get the country information relevant to the initial selection onInit: (code) => @@ -53,14 +52,13 @@ class _MyAppState extends State { padding: const EdgeInsets.all(8.0), child: CountryCodePicker( onChanged: print, + showFlagMain: true, + showFlag: false, initialSelection: 'TF', hideSearch: true, showCountryOnly: true, showOnlyCountryWhenClosed: true, alignLeft: true, - builder: (countryCode) { - return Text('${countryCode.code}'); - }, ), ), ), diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 3a56eed..e44a321 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -132,7 +132,9 @@ class CountryCodePickerState extends State { direction: Axis.horizontal, mainAxisSize: MainAxisSize.min, children: [ - if (widget.showFlag || (widget.showFlagMain == true)) + if (widget.showFlagMain != null + ? widget.showFlagMain + : widget.showFlag) Flexible( flex: widget.alignLeft ? 0 : 1, fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, @@ -231,7 +233,9 @@ class CountryCodePickerState extends State { searchDecoration: widget.searchDecoration, searchStyle: widget.searchStyle, textStyle: widget.dialogTextStyle, - showFlag: widget.showFlag || (widget.showFlagDialog == true), + showFlag: widget.showFlagDialog != null + ? widget.showFlagDialog + : widget.showFlag, flagWidth: widget.flagWidth, size: widget.dialogSize, hideSearch: widget.hideSearch,