Line data Source code
1 : part of 'foss_date_picker.dart';
2 :
3 : /// Visual overrides for a single [FossDatePicker]. Every field is optional; a
4 : /// null field falls back to the value the theme resolves. Pass one via `style:`
5 : /// to tweak a one-off without retheming.
6 : ///
7 : /// It carries only the date picker's own trigger knobs. The trigger chrome,
8 : /// the dialog surface, and the embedded calendar restyle through the theme or
9 : /// their own styles, not through here.
10 : ///
11 : /// ```dart
12 : /// FossDatePicker.single(
13 : /// selected: picked,
14 : /// onSelected: (day) => setState(() => picked = day),
15 : /// style: const FossDatePickerStyle(gap: 8),
16 : /// );
17 : /// ```
18 : @FossSince('0.1.1')
19 : @immutable
20 : class FossDatePickerStyle {
21 : /// Creates a set of trigger overrides. All fields default to null (inherit).
22 1 : const FossDatePickerStyle({this.placeholderColor, this.gap});
23 :
24 : /// Color of the placeholder label shown while nothing is selected.
25 : final Color? placeholderColor;
26 :
27 : /// Gap between the leading calendar glyph and the label, in logical pixels.
28 : final double? gap;
29 :
30 : /// Returns a copy with every non-null field of [other] laid over this one.
31 1 : FossDatePickerStyle merge(FossDatePickerStyle? other) {
32 : if (other == null) return this;
33 1 : return FossDatePickerStyle(
34 2 : placeholderColor: other.placeholderColor ?? placeholderColor,
35 1 : gap: other.gap ?? gap,
36 : );
37 : }
38 : }
|