From 7056cc1ffab68a078b00f2a020cd17c0a9413a80 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Sat, 16 May 2020 13:12:56 +0200 Subject: [PATCH] add hideMainText property --- example/lib/main.dart | 1 + lib/country_code_picker.dart | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index d425bc4..eca69d7 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -52,6 +52,7 @@ class _MyAppState extends State { padding: const EdgeInsets.all(8.0), child: CountryCodePicker( onChanged: print, + hideMainText: true, showFlagMain: true, showFlag: false, initialSelection: 'TF', diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index e44a321..2ef13f5 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -42,6 +42,8 @@ class CountryCodePicker extends StatefulWidget { /// shows the flag final bool showFlag; + final bool hideMainText; + final bool showFlagMain; final bool showFlagDialog; @@ -71,6 +73,7 @@ class CountryCodePicker extends StatefulWidget { this.alignLeft = false, this.showFlag = true, this.showFlagDialog, + this.hideMainText = false, this.showFlagMain, this.builder, this.flagWidth = 32.0, @@ -149,16 +152,17 @@ class CountryCodePickerState extends State { ), ), ), - Flexible( - fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, - child: Text( - widget.showOnlyCountryWhenClosed - ? selectedItem.toCountryStringOnly() - : selectedItem.toString(), - style: widget.textStyle ?? Theme.of(context).textTheme.button, - overflow: widget.textOverflow, + if (!widget.hideMainText) + Flexible( + fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, + child: Text( + widget.showOnlyCountryWhenClosed + ? selectedItem.toCountryStringOnly() + : selectedItem.toString(), + style: widget.textStyle ?? Theme.of(context).textTheme.button, + overflow: widget.textOverflow, + ), ), - ), ], ), );