Line data Source code
1 : part of 'foss_dialog.dart';
2 :
3 : /// Visual overrides for a single [FossAlertDialog]. An alert style is a
4 : /// [FossDialogStyle]: it carries the same fields and the alert composes a
5 : /// [FossDialog], so it passes its style straight through. Every field is
6 : /// optional; a null field falls back to the value the theme resolves. Pass one
7 : /// via `style:` to tweak a one-off without changing the theme.
8 : ///
9 : /// ```dart
10 : /// FossAlertDialog(
11 : /// title: const Text('Wide'),
12 : /// actions: [
13 : /// FossButton(
14 : /// onPressed: () => Navigator.pop(context),
15 : /// child: const Text('OK'),
16 : /// ),
17 : /// ],
18 : /// style: const FossAlertDialogStyle(maxWidth: 640),
19 : /// );
20 : /// ```
21 : @immutable
22 : class FossAlertDialogStyle extends FossDialogStyle {
23 : /// Creates a set of overrides. All fields default to null (inherit).
24 1 : const FossAlertDialogStyle({
25 : super.backgroundColor,
26 : super.borderColor,
27 : super.borderRadius,
28 : super.maxWidth,
29 : super.shadows,
30 : super.titleStyle,
31 : super.descriptionStyle,
32 : });
33 :
34 : /// Returns a copy with every non-null field of [other] laid over this one.
35 1 : @override
36 : FossAlertDialogStyle merge(covariant FossAlertDialogStyle? other) {
37 : if (other == null) return this;
38 1 : return FossAlertDialogStyle(
39 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
40 2 : borderColor: other.borderColor ?? borderColor,
41 2 : borderRadius: other.borderRadius ?? borderRadius,
42 2 : maxWidth: other.maxWidth ?? maxWidth,
43 2 : shadows: other.shadows ?? shadows,
44 2 : titleStyle: other.titleStyle ?? titleStyle,
45 2 : descriptionStyle: other.descriptionStyle ?? descriptionStyle,
46 : );
47 : }
48 : }
|