From 1ae3519333140cea610362f65577de2031f10289 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Sat, 29 Jun 2019 09:29:50 +0200 Subject: [PATCH] =?UTF-8?q?Refs=C2=A0#30:=20optional=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/country_code_picker.dart | 9 +++++++-- lib/selection_dialog.dart | 6 ++++-- pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index fb0fc0e..b342ae1 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -28,6 +28,9 @@ class CountryCodePicker extends StatefulWidget { /// because longer countrynames are displayed in one line final bool alignLeft; + /// shows the flag + final bool showFlag; + CountryCodePicker({ this.onChanged, this.initialSelection, @@ -40,6 +43,7 @@ class CountryCodePicker extends StatefulWidget { this.emptySearchBuilder, this.showOnlyCountryWhenClosed = false, this.alignLeft = false, + this.showFlag = true }); @override @@ -72,7 +76,7 @@ class _CountryCodePickerState extends State { direction: Axis.horizontal, mainAxisSize: MainAxisSize.min, children: [ - Flexible( + widget.showFlag ? Flexible( flex: widget.alignLeft ? 0 : 1, fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, child: Padding( @@ -85,7 +89,7 @@ class _CountryCodePickerState extends State { width: 32.0, ), ), - ), + ) : Container(), Flexible( fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, child: Text( @@ -134,6 +138,7 @@ class _CountryCodePickerState extends State { emptySearchBuilder: widget.emptySearchBuilder, searchDecoration: widget.searchDecoration, searchStyle: widget.searchStyle, + showFlag: widget.showFlag ), ).then((e) { if (e != null) { diff --git a/lib/selection_dialog.dart b/lib/selection_dialog.dart index 0f38ecf..f137089 100644 --- a/lib/selection_dialog.dart +++ b/lib/selection_dialog.dart @@ -8,6 +8,7 @@ class SelectionDialog extends StatefulWidget { final InputDecoration searchDecoration; final TextStyle searchStyle; final WidgetBuilder emptySearchBuilder; + final bool showFlag; /// elements passed as favorite final List favoriteElements; @@ -18,6 +19,7 @@ class SelectionDialog extends StatefulWidget { this.emptySearchBuilder, InputDecoration searchDecoration = const InputDecoration(), this.searchStyle, + this.showFlag }) : assert(searchDecoration != null, 'searchDecoration must not be null!'), this.searchDecoration = searchDecoration.copyWith(prefixIcon: Icon(Icons.search)), @@ -85,7 +87,7 @@ class _SelectionDialogState extends State { child: Flex( direction: Axis.horizontal, children: [ - Flexible( + widget.showFlag ? Flexible( child: Padding( padding: const EdgeInsets.only(right: 16.0), child: Image.asset( @@ -94,7 +96,7 @@ class _SelectionDialogState extends State { width: 32.0, ), ), - ), + ) : Container(), Expanded( flex: 4, child: Text( diff --git a/pubspec.yaml b/pubspec.yaml index d406b08..c242ad9 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.1.5 +version: 1.1.6 author: Salvatore-Giordano homepage: https://github.com/Salvatore-Giordano/CountryCodePicker