Reputation: 47
I want to make dropdown text field with suggestion list, How can I make this, please describe me
Expanded(
child: new TextField(
controller: _controller,
// decoration: InputDecoration(
)),
new PopupMenuButton(
icon: const Icon(Icons.arrow_drop_down),
onSelected: (value) {
_controller.text = value as String;
},
itemBuilder: (BuildContext context) {
return _loadedPacks.map<PopupMenuItem>((value) {
return new PopupMenuItem(
child: new Text(value["package_name"]),
value: value["package_name"]);
}).toList();
},
),
Upvotes: 1
Views: 5699
Reputation: 61
You can resolve this by the following 2 options:
Create your own AutoComplete Textfield using Autocomplete
widget. Ref: https://api.flutter.dev/flutter/material/Autocomplete-class.html
You can use flutter_typeahead
pub. Ref: https://pub.dev/packages/flutter_typeahead
Note: You can find the usage of both options in the link
Upvotes: 2