@@ -22,11 +22,9 @@ class ShadAlert extends StatelessWidget {
2222 this .iconSize,
2323 this .titleStyle,
2424 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;
3028
3129 const ShadAlert .destructive ({
3230 super .key,
@@ -41,11 +39,9 @@ class ShadAlert extends StatelessWidget {
4139 this .iconSize,
4240 this .titleStyle,
4341 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;
4945
5046 const ShadAlert .raw ({
5147 super .key,
@@ -61,10 +57,9 @@ class ShadAlert extends StatelessWidget {
6157 this .iconSize,
6258 this .titleStyle,
6359 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+ });
6863
6964 final ShadAlertVariant variant;
7065 final Widget ? icon;
@@ -78,6 +73,8 @@ class ShadAlert extends StatelessWidget {
7873 final Size ? iconSize;
7974 final TextStyle ? titleStyle;
8075 final TextStyle ? descriptionStyle;
76+ final MainAxisAlignment ? mainAxisAlignment;
77+ final CrossAxisAlignment ? crossAxisAlignment;
8178
8279 @override
8380 Widget build (BuildContext context) {
@@ -108,16 +105,19 @@ class ShadAlert extends StatelessWidget {
108105 final effectiveIconSize =
109106 iconSize ?? effectiveAlertTheme.iconSize ?? const Size .square (16 );
110107
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 ;
121121
122122 final effectiveTitleStyle = titleStyle ??
123123 effectiveAlertTheme.titleStyle ??
@@ -131,13 +131,22 @@ class ShadAlert extends StatelessWidget {
131131 effectiveAlertTheme.descriptionStyle ??
132132 theme.textTheme.muted.copyWith (color: theme.colorScheme.foreground);
133133
134+ final effectiveMainAxisAlignment = mainAxisAlignment ??
135+ effectiveAlertTheme.mainAxisAlignment ??
136+ MainAxisAlignment .start;
137+
138+ final effectiveCrossAxisAlignment = crossAxisAlignment ??
139+ effectiveAlertTheme.crossAxisAlignment ??
140+ CrossAxisAlignment .start;
141+
134142 return ShadDecorator (
135143 decoration: effectiveDecoration,
136144 child: Row (
137- crossAxisAlignment: CrossAxisAlignment .start,
145+ crossAxisAlignment: effectiveCrossAxisAlignment,
146+ mainAxisAlignment: effectiveMainAxisAlignment,
138147 textDirection: textDirection,
139148 children: [
140- effectiveIcon,
149+ if (effectiveIcon != null ) effectiveIcon,
141150 Flexible (
142151 child: Column (
143152 crossAxisAlignment: CrossAxisAlignment .start,
0 commit comments