selectedItemBuilder property
A builder to customize the combo box buttons corresponding to the ComboBoxItems in items.
When a ComboBoxItem is selected, the widget that will be displayed from the list corresponds to the ComboBoxItem of the same index in items.
This sample shows a ComboBox
with a button with Text that
corresponds to but is unique from ComboBoxItem.
final List<String> items = <String>['1','2','3'];
String selectedItem = '1';
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: ComboBox<String>(
value: selectedItem,
onChanged: (String? string) => setState(() => selectedItem = string!),
selectedItemBuilder: (BuildContext context) {
return items.map<Widget>((String item) {
return Text(item);
}).toList();
},
items: items.map((String item) {
return ComboBoxItem<String>(
child: Text('Log $item'),
value: item,
);
}).toList(),
),
);
}
If this callback is null, the ComboBoxItem from items that matches value will be displayed.
Implementation
final ComboBoxBuilder? selectedItemBuilder;