Line data Source code
1 : part of 'foss_progress.dart';
2 :
3 : /// Visual overrides for a single [FossProgress]. 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 changing the theme for every other bar.
6 : ///
7 : /// ```dart
8 : /// FossProgress(
9 : /// value: 0.4,
10 : /// style: const FossProgressStyle(fillColor: Color(0xFF16A34A)),
11 : /// );
12 : /// ```
13 : @immutable
14 : class FossProgressStyle {
15 : /// Creates a set of progress overrides. All fields default to null (inherit).
16 1 : const FossProgressStyle({
17 : this.trackColor,
18 : this.fillColor,
19 : this.labelStyle,
20 : this.valueLabelStyle,
21 : });
22 :
23 : /// Fill of the unfilled track.
24 : final Color? trackColor;
25 :
26 : /// Fill of the leading progress band.
27 : final Color? fillColor;
28 :
29 : /// Style of the [FossProgress.label]. Merged over the token default.
30 : final TextStyle? labelStyle;
31 :
32 : /// Style of the [FossProgress.valueLabel]. Merged over the token default.
33 : final TextStyle? valueLabelStyle;
34 :
35 : /// Returns a copy with every non-null field of [other] laid over this one.
36 1 : FossProgressStyle merge(FossProgressStyle? other) {
37 : if (other == null) return this;
38 1 : return FossProgressStyle(
39 2 : trackColor: other.trackColor ?? trackColor,
40 1 : fillColor: other.fillColor ?? fillColor,
41 2 : labelStyle: other.labelStyle ?? labelStyle,
42 2 : valueLabelStyle: other.valueLabelStyle ?? valueLabelStyle,
43 : );
44 : }
45 : }
|