selectedItemBuilder property

ComboboxBuilder? selectedItemBuilder
final

A builder to customize the combobox 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.

{@tool dartpad --template=stateful_widget_scaffold}

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(),
    ),
  );
}

{@end-tool}

If this callback is null, the ComboboxItem from items that matches value will be displayed.

Implementation

final ComboboxBuilder? selectedItemBuilder;