diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index c979e12b..1275e259 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -74,9 +74,15 @@ class CountryCodePicker extends StatefulWidget { /// Set to true if you want to hide the search part final bool hideSearch; + /// Set to true if you want to hide the Splash Button + final bool hideSplash; + /// Set to true if you want to show drop down button final bool showDropDownButton; + /// Set to true if you want to show drop down button + final Widget? customDropDownButton; + /// [BoxDecoration] for the flag image final Decoration? flagDecoration; @@ -113,7 +119,9 @@ class CountryCodePicker extends StatefulWidget { this.comparator, this.countryFilter, this.hideSearch = false, + this.hideSplash = false, this.showDropDownButton = false, + this.customDropDownButton, this.dialogSize, this.dialogBackgroundColor, this.closeIcon = const Icon(Icons.close), @@ -159,11 +167,15 @@ class CountryCodePickerState extends State { Widget _widget; if (widget.builder != null) _widget = InkWell( + splashFactory: widget.hideSplash ? NoSplash.splashFactory : null, onTap: showCountryCodePickerDialog, child: widget.builder!(selectedItem), ); else { _widget = TextButton( + style: TextButton.styleFrom( + splashFactory: widget.hideSplash ? NoSplash.splashFactory : null + ), onPressed: widget.enabled ? showCountryCodePickerDialog : null, child: Padding( padding: widget.padding, @@ -205,19 +217,23 @@ class CountryCodePickerState extends State { ), ), if (widget.showDropDownButton) - Flexible( - flex: widget.alignLeft ? 0 : 1, - fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, - child: Padding( - padding: widget.alignLeft - ? const EdgeInsets.only(right: 16.0, left: 8.0) - : const EdgeInsets.only(right: 16.0), - child: Icon( - Icons.arrow_drop_down, - color: Colors.grey, - size: widget.flagWidth, - )), - ), + if(widget.customDropDownButton==null)...[ + Flexible( + flex: widget.alignLeft ? 0 : 1, + fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, + child: Padding( + padding: widget.alignLeft + ? const EdgeInsets.only(right: 16.0, left: 8.0) + : const EdgeInsets.only(right: 16.0), + child: Icon( + Icons.arrow_drop_down, + color: Colors.grey, + size: widget.flagWidth, + )), + ), + ]else ...[ + widget.customDropDownButton!, + ] ], ), ), diff --git a/lib/selection_dialog.dart b/lib/selection_dialog.dart index 176d0ee2..43a5e4ea 100644 --- a/lib/selection_dialog.dart +++ b/lib/selection_dialog.dart @@ -79,35 +79,40 @@ class _SelectionDialogState extends State { ), ], ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - IconButton( - padding: const EdgeInsets.all(0), - iconSize: 20, - icon: widget.closeIcon!, - onPressed: () => Navigator.pop(context), - ), - if (!widget.hideSearch) - Padding( - padding: const EdgeInsets.symmetric(horizontal: 24), - child: TextField( - style: widget.searchStyle, - decoration: widget.searchDecoration, - onChanged: _filterElements, + child: Stack( + children: [ + Align( + alignment: Alignment.topRight, + child: IconButton( + padding: const EdgeInsets.all(0), + iconSize: 20, + icon: widget.closeIcon!, + onPressed: () => Navigator.pop(context), ), ), - Expanded( - child: ListView( + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, children: [ - widget.favoriteElements.isEmpty - ? const DecoratedBox(decoration: BoxDecoration()) - : Column( + if (!widget.hideSearch) + Padding( + padding: const EdgeInsets.only(left: 24, right: 24, top: 24), + child: TextField( + style: widget.searchStyle, + decoration: widget.searchDecoration, + onChanged: _filterElements, + ), + ), + Expanded( + child: ListView( + children: [ + widget.favoriteElements.isEmpty + ? const DecoratedBox(decoration: BoxDecoration()) + : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ...widget.favoriteElements.map( - (f) => SimpleDialogOption( + (f) => SimpleDialogOption( child: _buildOption(f), onPressed: () { _selectItem(f); @@ -117,22 +122,24 @@ class _SelectionDialogState extends State { const Divider(), ], ), - if (filteredElements.isEmpty) - _buildEmptySearchWidget(context) - else - ...filteredElements.map( - (e) => SimpleDialogOption( - child: _buildOption(e), - onPressed: () { - _selectItem(e); - }, - ), + if (filteredElements.isEmpty) + _buildEmptySearchWidget(context) + else + ...filteredElements.map( + (e) => SimpleDialogOption( + child: _buildOption(e), + onPressed: () { + _selectItem(e); + }, + ), + ), + ], ), + ), ], ), - ), - ], - ), + ], + ) ), );