Line data Source code
1 : part of 'foss_card.dart';
2 :
3 : /// Visual overrides for a single [FossCard]. 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 card.
6 : ///
7 : /// ```dart
8 : /// FossCard(
9 : /// content: const Text('Tinted'),
10 : /// style: FossCardStyle(borderColor: Colors.transparent),
11 : /// );
12 : /// ```
13 : @immutable
14 : class FossCardStyle {
15 : /// Creates a set of card overrides. All fields default to null (inherit).
16 1 : const FossCardStyle({
17 : this.backgroundColor,
18 : this.borderColor,
19 : this.borderRadius,
20 : this.shadows,
21 : this.titleStyle,
22 : this.descriptionStyle,
23 : });
24 :
25 : /// Fill of the card surface.
26 : final Color? backgroundColor;
27 :
28 : /// Color of the 1px surface border.
29 : final Color? borderColor;
30 :
31 : /// Corner radius of the surface in logical pixels.
32 : final double? borderRadius;
33 :
34 : /// Drop shadow layers under the surface; empty for none.
35 : final List<BoxShadow>? shadows;
36 :
37 : /// Style of the [FossCard.title]. Merged over the token default.
38 : final TextStyle? titleStyle;
39 :
40 : /// Style of the [FossCard.description]. Merged over the token default.
41 : final TextStyle? descriptionStyle;
42 :
43 : /// Returns a copy with every non-null field of [other] laid over this one.
44 1 : FossCardStyle merge(FossCardStyle? other) {
45 : if (other == null) return this;
46 1 : return FossCardStyle(
47 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
48 2 : borderColor: other.borderColor ?? borderColor,
49 1 : borderRadius: other.borderRadius ?? borderRadius,
50 2 : shadows: other.shadows ?? shadows,
51 2 : titleStyle: other.titleStyle ?? titleStyle,
52 2 : descriptionStyle: other.descriptionStyle ?? descriptionStyle,
53 : );
54 : }
55 : }
|