Combobox<T> constructor

Combobox<T>({
  1. Key? key,
  2. required List<ComboboxItem<T>>? items,
  3. ComboboxBuilder? selectedItemBuilder,
  4. T? value,
  5. Widget? placeholder,
  6. Widget? disabledHint,
  7. ValueChanged<T?>? onChanged,
  8. VoidCallback? onTap,
  9. int elevation = 8,
  10. TextStyle? style,
  11. Widget? icon,
  12. Color? iconDisabledColor,
  13. Color? iconEnabledColor,
  14. double iconSize = 24.0,
  15. bool isExpanded = false,
  16. double? itemHeight = kMinInteractiveDimension,
  17. Color? focusColor,
  18. FocusNode? focusNode,
  19. bool autofocus = false,
  20. Color? comboboxColor,
})

Creates a combobox button.

The items must have distinct values. If value isn't null then it must be equal to one of the ComboboxItem values. If items or onChanged is null, the button will be disabled, the down arrow will be greyed out.

If value is null and the button is enabled, placeholder will be displayed if it is non-null.

If value is null and the button is disabled, disabledHint will be displayed if it is non-null. If disabledHint is null, then placeholder will be displayed if it is non-null.

The elevation and iconSize arguments must not be null (they both have defaults, so do not need to be specified). The isExpanded arguments must not be null.

The autofocus argument must not be null.

The comboboxColor argument specifies the background color of the combobox when it is open. If it is null, the current theme's ThemeData.canvasColor will be used instead.

Implementation

Combobox({
  Key? key,
  required this.items,
  this.selectedItemBuilder,
  this.value,
  this.placeholder,
  this.disabledHint,
  this.onChanged,
  this.onTap,
  this.elevation = 8,
  this.style,
  this.icon,
  this.iconDisabledColor,
  this.iconEnabledColor,
  this.iconSize = 24.0,
  this.isExpanded = false,
  this.itemHeight = kMinInteractiveDimension,
  this.focusColor,
  this.focusNode,
  this.autofocus = false,
  this.comboboxColor,
  // When adding new arguments, consider adding similar arguments to
  // ComboboxFormField.
})  : assert(
        items == null ||
            items.isEmpty ||
            value == null ||
            items.where((ComboboxItem<T> item) {
                  return item.value == value;
                }).length ==
                1,
        "There should be exactly one item with [Combobox]'s value: "
        '$value. \n'
        'Either zero or 2 or more [ComboboxItem]s were detected '
        'with the same value',
      ),
      assert(itemHeight == null || itemHeight >= kMinInteractiveDimension),
      super(key: key);