clean name
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,59 +160,63 @@ 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: Flex(
|
child: Padding(
|
||||||
direction: Axis.horizontal,
|
padding: widget.padding,
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Flex(
|
||||||
children: <Widget>[
|
direction: Axis.horizontal,
|
||||||
if (widget.showFlagMain != null
|
mainAxisSize: MainAxisSize.min,
|
||||||
? widget.showFlagMain!
|
children: <Widget>[
|
||||||
: widget.showFlag)
|
if (widget.showFlagMain != null
|
||||||
Flexible(
|
? widget.showFlagMain!
|
||||||
flex: widget.alignLeft ? 0 : 1,
|
: widget.showFlag)
|
||||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
Flexible(
|
||||||
child: Container(
|
flex: widget.alignLeft ? 0 : 1,
|
||||||
clipBehavior:
|
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||||
widget.flagDecoration == null ? Clip.none : Clip.hardEdge,
|
child: Container(
|
||||||
decoration: widget.flagDecoration,
|
clipBehavior: widget.flagDecoration == null
|
||||||
margin: widget.alignLeft
|
? Clip.none
|
||||||
? const EdgeInsets.only(right: 16.0, left: 8.0)
|
: Clip.hardEdge,
|
||||||
: const EdgeInsets.only(right: 16.0),
|
decoration: widget.flagDecoration,
|
||||||
child: Image.asset(
|
margin: widget.alignLeft
|
||||||
selectedItem!.flagUri!,
|
|
||||||
package: 'country_code_picker',
|
|
||||||
width: widget.flagWidth,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
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, left: 8.0)
|
||||||
: const EdgeInsets.only(right: 16.0),
|
: const EdgeInsets.only(right: 16.0),
|
||||||
child: Icon(
|
child: Image.asset(
|
||||||
Icons.arrow_drop_down,
|
selectedItem!.flagUri!,
|
||||||
color: Colors.grey,
|
package: 'country_code_picker',
|
||||||
size: widget.flagWidth,
|
width: widget.flagWidth,
|
||||||
)),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user