SnackbarModal class
A modal widget specifically designed for snackbar-style notifications
Features:
- Swipe-to-dismiss (left/right/up/down)
- Auto-dismiss with optional duration
- Slide-in animation from bottom or top
- Support for stacking multiple snackbars
- Smooth fade animations during swipe gestures
- Internal animation controllers for each snackbar instance
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SnackbarModal
- Available extensions
Constructors
- SnackbarModal({Key? key, required Widget child, required Alignment position, required bool isDismissing, bool isSwipeable = true, Duration? autoDismissDuration, DateTime? autoDismissDeadline, dynamic onSwipeDismiss(String direction)?, int stackIndex = 0, int maxStacked = 3, String swipeDirection = '', double? width, Offset? offset, VoidCallback? onTap, String? snackbarId, SnackbarModalController? controller, Color barrierColor = Colors.transparent, bool blockBackgroundInteraction = false})
-
Creates a snackbar modal
const
Properties
- autoDismissDeadline → DateTime?
-
Absolute deadline for auto-dismiss.
final
- autoDismissDuration → Duration?
-
Duration before auto-dismiss (null means no auto-dismiss)
final
- barrierColor → Color
-
The color of the background barrier (defaults to transparent)
This barrier is displayed behind the snackbar and fades in/out with animations
final
- blockBackgroundInteraction → bool
-
Whether the snackbar barrier should block taps to widgets behind it.
final
- child → Widget
-
Content to display inside the snackbar
final
- controller → SnackbarModalController?
-
Controller for imperatively managing this snackbar's animations
Each snackbar should have its own unique controller to avoid conflicts
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDismissing → bool
-
Whether the snackbar is currently being dismissed
NOTE: This is now primarily used for initial state. For imperative
dismiss, use the controller's playDismissAnimation method instead.
final
- isSwipeable → bool
-
Whether the snackbar can be swiped to dismiss
Note: This is now controlled by the parent modal's isDismissable property.
If isDismissable is false, the snackbar cannot be swiped regardless of this setting.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxStacked → int
-
Maximum snackbars to display in staggered mode
final
- offset → Offset?
-
Optional offset for fine-tuned positioning
final
- onSwipeDismiss → dynamic Function(String direction)?
-
Called when the snackbar is dismissed by swipe, with direction ('left' or 'right')
final
- onTap → VoidCallback?
-
Called when the snackbar is tapped
In staggered mode, used to expand the view when a stacked snackbar is tapped
final
- position → Alignment
-
Where on screen the snackbar should be positioned
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- snackbarId → String?
-
Unique identifier for this snackbar instance
Used to create unique animation keys to prevent animation conflicts
final
- stackIndex → int
-
Stack index for staggered display (0 = front, 1+ = behind)
final
- swipeDirection → String
-
Swipe direction for the dismiss animation ('left', 'right', or '')
NOTE: This is now snackbar-specific and should not affect other snackbars
final
- width → double?
-
Width of the snackbar (default: 90% of screen width)
final
Methods
-
addMaterialWidget(
) → Material -
Available on Widget, provided by the GenericExtensions extension
-
addTooltipWidget(
String toolTip) → Tooltip -
Available on Widget, provided by the GenericExtensions extension
-
animate(
{Key? key, List< Effect> ? effects, AnimateCallback? onInit, AnimateCallback? onPlay, AnimateCallback? onComplete, bool? autoPlay, Duration? delay, AnimationController? controller, Adapter? adapter, double? target, double? value}) → Animate -
Available on Widget, provided by the AnimateWidgetExtensions extension
Wraps the target Widget in anAnimateinstance, and returns the instance for chaining calls. Ex.myWidget.animate()is equivalent toAnimate(child: myWidget). -
borderRadius(
[BorderRadiusGeometry? borderRadius]) → Widget -
Available on Widget, provided by the GenericExtensions extension
-
boxDecoration(
[BoxDecoration? boxDecoration]) → Widget -
Available on Widget, provided by the GenericExtensions extension
-
colorFilter(
[ColorFilter? colorFilter]) → Widget -
Available on Widget, provided by the GenericExtensions extension
set parent widget in center -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< SnackbarModal> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited