Line data Source code
1 : part of 'foss_combobox.dart';
2 :
3 : /// One option in a [FossCombobox].
4 : ///
5 : /// The [label] is the visible row text, the chip text when picked, and the
6 : /// target the filter matches against. [value] is the identity reported through
7 : /// the selection callback, compared by `==`. An optional [icon] renders before
8 : /// the label; it takes any widget, so the package stays icon-agnostic.
9 : ///
10 : /// ```dart
11 : /// const FossComboboxItem(value: 'a', label: 'Design');
12 : /// ```
13 : @immutable
14 : class FossComboboxItem<T> {
15 : /// Creates an option with a [value] and its visible [label].
16 2 : const FossComboboxItem({
17 : required this.value,
18 : required this.label,
19 : this.icon,
20 : this.enabled = true,
21 : });
22 :
23 : /// The identity reported when this option is picked, compared by `==`.
24 : final T value;
25 :
26 : /// The row and chip text, and the string the filter matches against.
27 : final String label;
28 :
29 : /// Optional leading glyph rendered before the label.
30 : final Widget? icon;
31 :
32 : /// Whether the option can be picked. A disabled option dims and ignores taps.
33 : final bool enabled;
34 : }
|