@@ -106,6 +106,7 @@ class MaterialBanner extends StatefulWidget {
106
106
this .shadowColor,
107
107
this .dividerColor,
108
108
this .padding,
109
+ this .margin,
109
110
this .leadingPadding,
110
111
this .forceActionsBelow = false ,
111
112
this .overflowAlignment = OverflowBarAlignment .end,
@@ -185,6 +186,12 @@ class MaterialBanner extends StatefulWidget {
185
186
/// `EdgeInsetsDirectional.only(start: 16.0, top: 2.0)` .
186
187
final EdgeInsetsGeometry ? padding;
187
188
189
+ /// Empty space to surround the [MaterialBanner] .
190
+ ///
191
+ /// If the [margin] is null then this defaults to
192
+ /// 0 if the banner's [elevation] is 0, 10 otherwise.
193
+ final EdgeInsetsGeometry ? margin;
194
+
188
195
/// The amount of space by which to inset the [leading] widget.
189
196
///
190
197
/// This defaults to `EdgeInsetsDirectional.only(end: 16.0)` .
@@ -237,6 +244,7 @@ class MaterialBanner extends StatefulWidget {
237
244
leading: leading,
238
245
backgroundColor: backgroundColor,
239
246
padding: padding,
247
+ margin: margin,
240
248
leadingPadding: leadingPadding,
241
249
forceActionsBelow: forceActionsBelow,
242
250
overflowAlignment: overflowAlignment,
@@ -318,6 +326,7 @@ class _MaterialBannerState extends State<MaterialBanner> {
318
326
);
319
327
320
328
final double elevation = widget.elevation ?? bannerTheme.elevation ?? 0.0 ;
329
+ final EdgeInsetsGeometry margin = widget.margin ?? EdgeInsets .only (bottom: elevation > 0 ? 10.0 : 0.0 );
321
330
final Color backgroundColor = widget.backgroundColor
322
331
?? bannerTheme.backgroundColor
323
332
?? defaults.backgroundColor! ;
@@ -334,7 +343,7 @@ class _MaterialBannerState extends State<MaterialBanner> {
334
343
?? defaults.contentTextStyle;
335
344
336
345
Widget materialBanner = Container (
337
- margin: EdgeInsets . only (bottom : elevation > 0 ? 10.0 : 0.0 ) ,
346
+ margin: margin ,
338
347
child: Material (
339
348
elevation: elevation,
340
349
color: backgroundColor,
0 commit comments