Line data Source code
1 : part of 'foss_toast.dart';
2 :
3 : /// Visual overrides for a single [FossToast]. Every field is optional; a null
4 : /// field falls back to the value the theme resolves.
5 : ///
6 : /// ```dart
7 : /// const FossToast(
8 : /// title: Text('Saved'),
9 : /// style: FossToastStyle(borderRadius: 8),
10 : /// );
11 : /// ```
12 : @immutable
13 : class FossToastStyle {
14 : /// Creates a set of toast overrides. All fields default to null (inherit).
15 1 : const FossToastStyle({
16 : this.backgroundColor,
17 : this.borderColor,
18 : this.borderRadius,
19 : this.titleStyle,
20 : this.descriptionStyle,
21 : });
22 :
23 : /// Fill of the surface.
24 : final Color? backgroundColor;
25 :
26 : /// Color of the 1px border.
27 : final Color? borderColor;
28 :
29 : /// Corner radius in logical pixels.
30 : final double? borderRadius;
31 :
32 : /// Style of the [FossToast.title]. Merged over the token default.
33 : final TextStyle? titleStyle;
34 :
35 : /// Style of the [FossToast.description]. Merged over the token default.
36 : final TextStyle? descriptionStyle;
37 :
38 : /// Returns a copy with every non-null field of [other] laid over this one.
39 1 : FossToastStyle merge(FossToastStyle? other) {
40 : if (other == null) return this;
41 1 : return FossToastStyle(
42 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
43 2 : borderColor: other.borderColor ?? borderColor,
44 2 : borderRadius: other.borderRadius ?? borderRadius,
45 2 : titleStyle: other.titleStyle ?? titleStyle,
46 2 : descriptionStyle: other.descriptionStyle ?? descriptionStyle,
47 : );
48 : }
49 : }
|