enable custom view widgets;

This commit is contained in:
Saif Allah Khaled
2019-09-05 16:21:10 +02:00
parent 894ffd7c9e
commit 9d64157171

View File

@@ -76,45 +76,48 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget _widget; Widget _widget;
if (widget.customWidget != null) if (widget.customWidget != null)
_widget = widget.customWidget; _widget = InkWell(
onTap: _showSelectionDialog,
child: widget.customWidget,
);
else { else {
_widget = Flex( _widget = FlatButton(
direction: Axis.horizontal, padding: widget.padding,
mainAxisSize: MainAxisSize.min, onPressed: _showSelectionDialog,
children: <Widget>[ child: Flex(
widget.showFlag direction: Axis.horizontal,
? Flexible( mainAxisSize: MainAxisSize.min,
flex: widget.alignLeft ? 0 : 1, children: <Widget>[
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, widget.showFlag
child: Padding( ? Flexible(
padding: widget.alignLeft flex: widget.alignLeft ? 0 : 1,
? const EdgeInsets.only(right: 16.0, left: 8.0) fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
: const EdgeInsets.only(right: 16.0), child: Padding(
child: Image.asset( padding: widget.alignLeft
selectedItem.flagUri, ? const EdgeInsets.only(right: 16.0, left: 8.0)
package: 'country_code_picker', : const EdgeInsets.only(right: 16.0),
width: 32.0, child: Image.asset(
selectedItem.flagUri,
package: 'country_code_picker',
width: 32.0,
),
), ),
), )
) : Container(),
: Container(), Flexible(
Flexible( fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, child: Text(
child: Text( 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, ),
), ),
), ],
], ),
); );
} }
return FlatButton( return _widget;
child: _widget,
padding: widget.padding,
onPressed: _showSelectionDialog,
);
} }
@override @override