ModalBuilder.snackbar constructor
const
ModalBuilder.snackbar({
- Key? key,
- ModalWidgetBuilder? builder,
- required Widget child,
- bool shouldBlurBackground = false,
- double blurAmount = 3.0,
- Function? onDismissed,
- bool isDismissable = true,
- double? size,
- Alignment modalPosition = Alignment.bottomCenter,
- ModalAnimationType modalAnimationType = ModalAnimationType.slide,
- bool isSwipeable = true,
- Duration? autoDismissDuration = const Duration(seconds: 4),
- SnackbarDisplayMode snackbarDisplayMode = SnackbarDisplayMode.replace,
- int maxStackedSnackbars = 3,
- Color barrierColor = Colors.transparent,
- bool blockBackgroundInteraction = false,
- double? snackbarWidth,
- String? id,
Creates a ModalBuilder for snackbar modals
Snackbars appear at the bottom of the screen by default, designed for brief notifications and messages.
Features:
isDismissable: Controls whether snackbar can be dismissed by swipe or tap (default: true)autoDismissDuration: Auto-dismiss after duration (default: 4 seconds, null if isDismissable is false)snackbarDisplayMode: How multiple snackbars stack (staggered/notificationBubble)maxStackedSnackbars: Max visible stacked snackbars (default: 3)barrierColor: Background barrier color (default: transparent)
Note: For snackbars, isDismissable controls all dismissal methods including swipe. If isDismissable is false, autoDismissDuration is treated as null.
ModalBuilder.snackbar(
builder: () => MySnackbarContent(),
autoDismissDuration: Duration(seconds: 3),
isDismissable: true,
barrierColor: Colors.black.withValues(alpha: 0.2),
child: ElevatedButton(child: Text('Show Snackbar')),
)
Implementation
const ModalBuilder.snackbar({
super.key,
this.builder,
required this.child,
this.shouldBlurBackground = false,
this.blurAmount = 3.0,
this.onDismissed,
this.isDismissable = true,
this.size,
this.modalPosition = Alignment.bottomCenter,
this.modalAnimationType = ModalAnimationType.slide,
this.isSwipeable = true,
this.autoDismissDuration = const Duration(seconds: 4),
this.snackbarDisplayMode = SnackbarDisplayMode.replace,
this.maxStackedSnackbars = 3,
this.barrierColor = Colors.transparent,
this.blockBackgroundInteraction = false,
this.snackbarWidth,
this.id,
}) : modalType = ModalType.snackbar,
onExpanded = null,
isExpandable = false,
expandedPercentageSize = 85,
contentPaddingByDragHandle = 0.0,
isDraggable = false,
modalColor = null;