@@ -22,11 +22,9 @@ class ShadAlert extends StatelessWidget {
22
22
this .iconSize,
23
23
this .titleStyle,
24
24
this .descriptionStyle,
25
- }) : variant = ShadAlertVariant .primary,
26
- assert (
27
- (icon != null ) ^ (iconSrc != null ),
28
- 'Either icon or iconSrc must be provided' ,
29
- );
25
+ this .mainAxisAlignment,
26
+ this .crossAxisAlignment,
27
+ }) : variant = ShadAlertVariant .primary;
30
28
31
29
const ShadAlert .destructive ({
32
30
super .key,
@@ -41,11 +39,9 @@ class ShadAlert extends StatelessWidget {
41
39
this .iconSize,
42
40
this .titleStyle,
43
41
this .descriptionStyle,
44
- }) : variant = ShadAlertVariant .destructive,
45
- assert (
46
- (icon != null ) ^ (iconSrc != null ),
47
- 'Either icon or iconSrc must be provided' ,
48
- );
42
+ this .mainAxisAlignment,
43
+ this .crossAxisAlignment,
44
+ }) : variant = ShadAlertVariant .destructive;
49
45
50
46
const ShadAlert .raw ({
51
47
super .key,
@@ -61,10 +57,9 @@ class ShadAlert extends StatelessWidget {
61
57
this .iconSize,
62
58
this .titleStyle,
63
59
this .descriptionStyle,
64
- }) : assert (
65
- (icon != null ) ^ (iconSrc != null ),
66
- 'Either icon or iconSrc must be provided' ,
67
- );
60
+ this .mainAxisAlignment,
61
+ this .crossAxisAlignment,
62
+ });
68
63
69
64
final ShadAlertVariant variant;
70
65
final Widget ? icon;
@@ -78,6 +73,8 @@ class ShadAlert extends StatelessWidget {
78
73
final Size ? iconSize;
79
74
final TextStyle ? titleStyle;
80
75
final TextStyle ? descriptionStyle;
76
+ final MainAxisAlignment ? mainAxisAlignment;
77
+ final CrossAxisAlignment ? crossAxisAlignment;
81
78
82
79
@override
83
80
Widget build (BuildContext context) {
@@ -108,16 +105,19 @@ class ShadAlert extends StatelessWidget {
108
105
final effectiveIconSize =
109
106
iconSize ?? effectiveAlertTheme.iconSize ?? const Size .square (16 );
110
107
111
- final effectiveIcon = Padding (
112
- padding: effectiveIconPadding,
113
- child: icon ??
114
- ShadImage (
115
- iconSrc! ,
116
- width: effectiveIconSize.width,
117
- height: effectiveIconSize.height,
118
- color: effectiveIconColor,
119
- ),
120
- );
108
+ final hasIcon = icon != null || iconSrc != null ;
109
+ final effectiveIcon = hasIcon
110
+ ? Padding (
111
+ padding: effectiveIconPadding,
112
+ child: icon ??
113
+ ShadImage (
114
+ iconSrc! ,
115
+ width: effectiveIconSize.width,
116
+ height: effectiveIconSize.height,
117
+ color: effectiveIconColor,
118
+ ),
119
+ )
120
+ : null ;
121
121
122
122
final effectiveTitleStyle = titleStyle ??
123
123
effectiveAlertTheme.titleStyle ??
@@ -131,13 +131,22 @@ class ShadAlert extends StatelessWidget {
131
131
effectiveAlertTheme.descriptionStyle ??
132
132
theme.textTheme.muted.copyWith (color: theme.colorScheme.foreground);
133
133
134
+ final effectiveMainAxisAlignment = mainAxisAlignment ??
135
+ effectiveAlertTheme.mainAxisAlignment ??
136
+ MainAxisAlignment .start;
137
+
138
+ final effectiveCrossAxisAlignment = crossAxisAlignment ??
139
+ effectiveAlertTheme.crossAxisAlignment ??
140
+ CrossAxisAlignment .start;
141
+
134
142
return ShadDecorator (
135
143
decoration: effectiveDecoration,
136
144
child: Row (
137
- crossAxisAlignment: CrossAxisAlignment .start,
145
+ crossAxisAlignment: effectiveCrossAxisAlignment,
146
+ mainAxisAlignment: effectiveMainAxisAlignment,
138
147
textDirection: textDirection,
139
148
children: [
140
- effectiveIcon,
149
+ if (effectiveIcon != null ) effectiveIcon,
141
150
Flexible (
142
151
child: Column (
143
152
crossAxisAlignment: CrossAxisAlignment .start,
0 commit comments