Update country_code_picker.dart

This commit is contained in:
Sherif Hasan
2020-11-05 14:07:24 +02:00
committed by GitHub
parent c283da595f
commit a99c34e2ac

View File

@@ -68,6 +68,9 @@ class CountryCodePicker extends StatefulWidget {
/// Set to true if you want to hide the search part /// Set to true if you want to hide the search part
final bool hideSearch; final bool hideSearch;
/// Set to true if you want to show drop down button
final bool showDropDownButton;
CountryCodePicker({ CountryCodePicker({
this.onChanged, this.onChanged,
this.onInit, this.onInit,
@@ -96,6 +99,7 @@ class CountryCodePicker extends StatefulWidget {
this.comparator, this.comparator,
this.countryFilter, this.countryFilter,
this.hideSearch = false, this.hideSearch = false,
this.showDropDownButton = false,
this.dialogSize, this.dialogSize,
this.closeIcon = const Icon(Icons.close), this.closeIcon = const Icon(Icons.close),
Key key, Key key,
@@ -150,6 +154,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
direction: Axis.horizontal, direction: Axis.horizontal,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
if (widget.showFlagMain != null if (widget.showFlagMain != null
? widget.showFlagMain ? widget.showFlagMain
: widget.showFlag) : widget.showFlag)
@@ -167,6 +172,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
), ),
), ),
), ),
if (!widget.hideMainText) if (!widget.hideMainText)
Flexible( Flexible(
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
@@ -174,10 +180,25 @@ class CountryCodePickerState extends State<CountryCodePicker> {
widget.showOnlyCountryWhenClosed widget.showOnlyCountryWhenClosed
? selectedItem.toCountryStringOnly() ? selectedItem.toCountryStringOnly()
: selectedItem.toString(), : selectedItem.toString(),
style: widget.textStyle ?? Theme.of(context).textTheme.button, style: widget.textStyle ?? Theme
.of(context)
.textTheme
.button,
overflow: widget.textOverflow, overflow: widget.textOverflow,
), ),
), ),
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,)
),
),
], ],
), ),
); );
@@ -245,7 +266,8 @@ class CountryCodePickerState extends State<CountryCodePicker> {
barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5), barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5),
backgroundColor: widget.backgroundColor ?? Colors.transparent, backgroundColor: widget.backgroundColor ?? Colors.transparent,
context: context, context: context,
builder: (context) => Center( builder: (context) =>
Center(
child: SelectionDialog( child: SelectionDialog(
elements, elements,
favoriteElements, favoriteElements,