clean name

This commit is contained in:
Salvatore Giordano
2021-03-13 12:37:04 +01:00
parent 4e8b890381
commit 01aa7502cc
3 changed files with 61 additions and 52 deletions

View File

@@ -4,6 +4,7 @@
- use modal_bottom_sheet 2.0.0 - use modal_bottom_sheet 2.0.0
- nullable integration - nullable integration
- switch to dialog on desktop app support - switch to dialog on desktop app support
- added flagDecoration
## 1.7.0 ## 1.7.0

View File

@@ -69,6 +69,10 @@ class CountryCode {
String toLongString() => "$dialCode ${toCountryStringOnly()}"; String toLongString() => "$dialCode ${toCountryStringOnly()}";
String toCountryStringOnly() { String toCountryStringOnly() {
return '$name'; return '$_cleanName';
}
String? get _cleanName {
return name?.replaceAll(RegExp(r'[[\]]'), '').split(',').first;
} }
} }

View File

@@ -87,7 +87,7 @@ class CountryCodePicker extends StatefulWidget {
this.initialSelection, this.initialSelection,
this.favorite = const [], this.favorite = const [],
this.textStyle, this.textStyle,
this.padding = const EdgeInsets.all(0.0), this.padding = const EdgeInsets.all(8.0),
this.showCountryOnly = false, this.showCountryOnly = false,
this.searchDecoration = const InputDecoration(), this.searchDecoration = const InputDecoration(),
this.searchStyle, this.searchStyle,
@@ -160,9 +160,10 @@ class CountryCodePickerState extends State<CountryCodePicker> {
child: widget.builder!(selectedItem), child: widget.builder!(selectedItem),
); );
else { else {
_widget = FlatButton( _widget = TextButton(
padding: widget.padding,
onPressed: widget.enabled ? showCountryCodePickerDialog : null, onPressed: widget.enabled ? showCountryCodePickerDialog : null,
child: Padding(
padding: widget.padding,
child: Flex( child: Flex(
direction: Axis.horizontal, direction: Axis.horizontal,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -174,8 +175,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
flex: widget.alignLeft ? 0 : 1, flex: widget.alignLeft ? 0 : 1,
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
child: Container( child: Container(
clipBehavior: clipBehavior: widget.flagDecoration == null
widget.flagDecoration == null ? Clip.none : Clip.hardEdge, ? Clip.none
: Clip.hardEdge,
decoration: widget.flagDecoration, decoration: widget.flagDecoration,
margin: widget.alignLeft margin: widget.alignLeft
? const EdgeInsets.only(right: 16.0, left: 8.0) ? const EdgeInsets.only(right: 16.0, left: 8.0)
@@ -194,7 +196,8 @@ 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,
), ),
), ),
@@ -214,6 +217,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
), ),
], ],
), ),
),
); );
} }
return _widget; return _widget;