SnackBar constructor
- Key? key,
- required Widget content,
- Color? backgroundColor,
- double? elevation,
- EdgeInsetsGeometry? margin,
- EdgeInsetsGeometry? padding,
- double? width,
- ShapeBorder? shape,
- HitTestBehavior? hitTestBehavior,
- SnackBarBehavior? behavior,
- SnackBarAction? action,
- double? actionOverflowThreshold,
- bool? showCloseIcon,
- Color? closeIconColor,
- Duration duration = _snackBarDisplayDuration,
- Animation<
double> ? animation, - VoidCallback? onVisible,
- DismissDirection? dismissDirection,
- Clip clipBehavior = Clip.hardEdge,
Creates a snack bar.
The elevation must be null or non-negative.
Implementation
const SnackBar({
super.key,
required this.content,
this.backgroundColor,
this.elevation,
this.margin,
this.padding,
this.width,
this.shape,
this.hitTestBehavior,
this.behavior,
this.action,
this.actionOverflowThreshold,
this.showCloseIcon,
this.closeIconColor,
this.duration = _snackBarDisplayDuration,
this.animation,
this.onVisible,
this.dismissDirection,
this.clipBehavior = Clip.hardEdge,
}) : assert(elevation == null || elevation >= 0.0),
assert(width == null || margin == null,
'Width and margin can not be used together',
),
assert(actionOverflowThreshold == null || (actionOverflowThreshold >= 0 && actionOverflowThreshold <= 1),
'Action overflow threshold must be between 0 and 1 inclusive');