I think would be better for the user if I show an YES/NO dialog before clear all options.
So, as I needed this in my app, I made a small modification on searchable_dropdown.dart, inside the clearSelection() function.
If there is a better place to make this modification, please tell me.
Thanks!
clearSelection() {
var yes = FlatButton(
child: Text('YES'),
onPressed: () {
Navigator.of(context).pop();
//--------- ORIGINAL CODE -------------------
selectedItems.clear();
if (widget.onChanged != null) {
widget.onChanged(selectedResult);
}
if (widget.onClear != null) {
widget.onClear();
}
//-----------------------------------
},
);
var no = FlatButton(
child: Text('NO'),
onPressed: () async {
Navigator.of(context).pop();
},
);
var alert = AlertDialog(
title: Text('Remove all?'),
content: Text('This will remove all saved options.'),
actions: [no, yes],
);
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
setState(() {});
}
}
I think would be better for the user if I show an YES/NO dialog before clear all options. So, as I needed this in my app, I made a small modification on
searchable_dropdown.dart
, inside theclearSelection()
function.If there is a better place to make this modification, please tell me. Thanks!