Line data Source code
1 : part of 'foss_meter.dart';
2 :
3 : /// Visual overrides for a single [FossMeter]. Every field is optional; a null
4 : /// field falls back to the value the theme resolves. Pass one via `style:` to
5 : /// tweak a one-off without changing the theme for every other gauge.
6 : ///
7 : /// ```dart
8 : /// FossMeter(
9 : /// value: 40,
10 : /// style: const FossMeterStyle(fillColor: Color(0xFF16A34A)),
11 : /// );
12 : /// ```
13 : @FossSince('0.1.1')
14 : @immutable
15 : class FossMeterStyle {
16 : /// Creates a set of meter overrides. All fields default to null (inherit).
17 1 : const FossMeterStyle({
18 : this.trackColor,
19 : this.fillColor,
20 : this.labelStyle,
21 : this.valueStyle,
22 : });
23 :
24 : /// Fill of the unfilled track.
25 : final Color? trackColor;
26 :
27 : /// Fill of the leading gauge band.
28 : final Color? fillColor;
29 :
30 : /// Style of the [FossMeter.label]. Merged over the token default.
31 : final TextStyle? labelStyle;
32 :
33 : /// Style of the value text. Merged over the token default.
34 : final TextStyle? valueStyle;
35 :
36 : /// Returns a copy with every non-null field of [other] laid over this one.
37 1 : FossMeterStyle merge(FossMeterStyle? other) {
38 : if (other == null) return this;
39 1 : return FossMeterStyle(
40 2 : trackColor: other.trackColor ?? trackColor,
41 1 : fillColor: other.fillColor ?? fillColor,
42 2 : labelStyle: other.labelStyle ?? labelStyle,
43 2 : valueStyle: other.valueStyle ?? valueStyle,
44 : );
45 : }
46 : }
|