refs #60: expose state to let use a key to open the dialog
This commit is contained in:
@@ -78,7 +78,8 @@ class CountryCodePicker extends StatefulWidget {
|
||||
this.comparator,
|
||||
this.customList,
|
||||
this.dialogSize,
|
||||
});
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -104,29 +105,29 @@ class CountryCodePicker extends StatefulWidget {
|
||||
elements = elements.where((c) => countryFilter.contains(c.code)).toList();
|
||||
}
|
||||
|
||||
return _CountryCodePickerState(elements);
|
||||
return CountryCodePickerState(elements);
|
||||
}
|
||||
}
|
||||
|
||||
class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
CountryCode selectedItem;
|
||||
List<CountryCode> elements = [];
|
||||
List<CountryCode> favoriteElements = [];
|
||||
|
||||
_CountryCodePickerState(this.elements);
|
||||
CountryCodePickerState(this.elements);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget _widget;
|
||||
if (widget.builder != null)
|
||||
_widget = InkWell(
|
||||
onTap: _showSelectionDialog,
|
||||
onTap: showCountryCodePickerDialog,
|
||||
child: widget.builder(selectedItem.localize(context)),
|
||||
);
|
||||
else {
|
||||
_widget = FlatButton(
|
||||
padding: widget.padding,
|
||||
onPressed: widget.enabled ? _showSelectionDialog : null,
|
||||
onPressed: widget.enabled ? showCountryCodePickerDialog : null,
|
||||
child: Flex(
|
||||
direction: Axis.horizontal,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -205,7 +206,7 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void _showSelectionDialog() {
|
||||
void showCountryCodePickerDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => SelectionDialog(
|
||||
|
||||
Reference in New Issue
Block a user