select_dialog package
package designed to select an item from a list, with the option to filter and even search the items online.
pubspec.yaml
select_dialog: <last version>
import
import 'package:select_dialog/select_dialog.dart';
simple example
string ex1 = "no value selected";
selectdialog.showmodal<string>(
context,
label: "simple example",
selectedvalue: ex1,
items: list.generate(50, (index) => "item $index"),
onchange: (string selected) {
setstate(() {
ex1 = selected;
});
},
);
attention
to use a template as an item type, you need to implement tostring, equals and hashcode, as shown below:
class usermodel {
final string id;
final datetime createdat;
final string name;
final string avatar;
usermodel({this.id, this.createdat, this.name, this.avatar});
@override
string tostring() => name;
@override
operator ==(o) => o is usermodel && o.id == id;
@override
int get hashcode => id.hashcode^name.hashcode^createdat.hashcode;
}
Comments are closed.