Line data Source code
1 : part of 'foss_select.dart';
2 :
3 : /// One option in a [FossSelect] or [FossMultiSelect].
4 : ///
5 : /// Carries the [value] it contributes to the selection, the [label] rendered on
6 : /// its row and, for a single pick, in the trigger, an optional leading [icon],
7 : /// and whether it [enabled] accepts a pick. The [value] is compared by `==`, so
8 : /// value types or identity both work.
9 : ///
10 : /// ```dart
11 : /// const FossSelectItem(value: 'monthly', label: 'Monthly');
12 : /// ```
13 : @immutable
14 : class FossSelectItem<T> {
15 : /// Creates a select option. [value] and [label] are required.
16 1 : const FossSelectItem({
17 : required this.value,
18 : required this.label,
19 : this.icon,
20 : this.enabled = true,
21 : });
22 :
23 : /// The value this option contributes to the selection, compared by `==`.
24 : final T value;
25 :
26 : /// The text shown on the row and, for a single pick, in the trigger.
27 : final String label;
28 :
29 : /// Optional leading glyph. Any widget works; the package takes no icon
30 : /// dependency.
31 : final Widget? icon;
32 :
33 : /// Whether this option accepts a pick. A disabled option is dimmed and
34 : /// non-interactive, still exposed to assistive technology.
35 : final bool enabled;
36 : }
37 :
38 : /// The height and type scale of a [FossSelect] or [FossMultiSelect] trigger.
39 : enum FossSelectSize {
40 : /// Compact: a 32 logical-pixel trigger with the small type scale.
41 : sm,
42 :
43 : /// Default: a 36 logical-pixel trigger with the base type scale.
44 : md,
45 :
46 : /// Large: a 40 logical-pixel trigger with the base type scale.
47 : lg,
48 : }
|