selectedItemBuilder property

DropdownButtonBuilder selectedItemBuilder
final

A builder to customize the dropdown buttons corresponding to the DropdownMenuItems in items.

When a DropdownMenuItem is selected, the widget that will be displayed from the list corresponds to the DropdownMenuItem of the same index in items.

This sample shows a DropdownButton with a button with Text that corresponds to but is unique from DropdownMenuItem.
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: DropdownButton<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 DropdownMenuItem<String>(
          child: Text('Log $item'),
          value: item,
        );
      }).toList(),
    ),
  );
}

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

Implementation

final DropdownButtonBuilder selectedItemBuilder