Line data Source code
1 : part of 'foss_combobox.dart';
2 :
3 : /// Visual overrides for a [FossAutocomplete] or [FossCombobox]. Every field is
4 : /// optional; a null field falls back to the theme-resolved value.
5 : ///
6 : /// State-derived colors (the focus ring, the error border, the row highlight)
7 : /// stay token-driven. To restyle those globally, retheme `FossColors`.
8 : ///
9 : /// ```dart
10 : /// FossCombobox<String>(
11 : /// items: items,
12 : /// style: const FossComboboxStyle(borderRadius: 12),
13 : /// );
14 : /// ```
15 : @immutable
16 : class FossComboboxStyle {
17 : /// Creates a set of overrides. All fields default to null (inherit).
18 1 : const FossComboboxStyle({
19 : this.backgroundColor,
20 : this.borderColor,
21 : this.borderRadius,
22 : this.textStyle,
23 : this.shadow,
24 : });
25 :
26 : /// Fill color of the input box and chips field.
27 : final Color? backgroundColor;
28 :
29 : /// Resting border color, used when neither focused nor invalid.
30 : final Color? borderColor;
31 :
32 : /// Corner radius of the input, chips field, and popup in logical pixels.
33 : final double? borderRadius;
34 :
35 : /// Style of the value, placeholder, and row text. Its color is ignored;
36 : /// text colors stay token-driven.
37 : final TextStyle? textStyle;
38 :
39 : /// Drop shadow layers on the input at rest; empty for none.
40 : final List<BoxShadow>? shadow;
41 :
42 : /// Returns a copy with every non-null field of [other] laid over this one.
43 1 : FossComboboxStyle merge(FossComboboxStyle? other) {
44 : if (other == null) return this;
45 1 : return FossComboboxStyle(
46 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
47 2 : borderColor: other.borderColor ?? borderColor,
48 1 : borderRadius: other.borderRadius ?? borderRadius,
49 2 : textStyle: other.textStyle ?? textStyle,
50 2 : shadow: other.shadow ?? shadow,
51 : );
52 : }
53 : }
|