ModalBuilder.snackbar constructor

const ModalBuilder.snackbar({
  1. Key? key,
  2. ModalWidgetBuilder? builder,
  3. required Widget child,
  4. bool shouldBlurBackground = false,
  5. double blurAmount = 3.0,
  6. Function? onDismissed,
  7. bool isDismissable = true,
  8. double? size,
  9. Alignment modalPosition = Alignment.bottomCenter,
  10. ModalAnimationType modalAnimationType = ModalAnimationType.slide,
  11. bool isSwipeable = true,
  12. Duration? autoDismissDuration = const Duration(seconds: 4),
  13. SnackbarDisplayMode snackbarDisplayMode = SnackbarDisplayMode.replace,
  14. int maxStackedSnackbars = 3,
  15. Color barrierColor = Colors.transparent,
  16. bool blockBackgroundInteraction = false,
  17. double? snackbarWidth,
  18. 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;