Dismissible class

A widget that can be dismissed by dragging in the indicated direction.

Dragging or flinging this widget in the DismissDirection causes the child to slide out of view. Following the slide animation, if resizeDuration is non-null, the Dismissible widget animates its height (or width, whichever is perpendicular to the dismiss direction) to zero over the resizeDuration.

This sample shows how you can use the Dismissible widget to remove list items using swipe gestures. Swipe any of the list tiles to the left or right to dismiss them from the ListView.

To create a local project with this code sample, run:
flutter create --sample=widgets.Dismissible.1 mysample

Backgrounds can be used to implement the "leave-behind" idiom. If a background is specified it is stacked behind the Dismissible's child and is exposed when the child moves.

The widget calls the onDismissed callback either after its size has collapsed to zero (if resizeDuration is non-null) or immediately after the slide animation (if resizeDuration is null). If the Dismissible is a list item, it must have a key that distinguishes it from the other items and its onDismissed callback must remove the item from the list.



Dismissible({required Key key, required Widget child, Widget? background, Widget? secondaryBackground, ConfirmDismissCallback? confirmDismiss, VoidCallback? onResize, DismissUpdateCallback? onUpdate, DismissDirectionCallback? onDismissed, DismissDirection direction = DismissDirection.horizontal, Duration? resizeDuration = const Duration(milliseconds: 300), Map<DismissDirection, double> dismissThresholds = const <DismissDirection, double>{}, Duration movementDuration = const Duration(milliseconds: 200), double crossAxisEndOffset = 0.0, DragStartBehavior dragStartBehavior = DragStartBehavior.start, HitTestBehavior behavior = HitTestBehavior.opaque})
Creates a widget that can be dismissed.


background Widget?
A widget that is stacked behind the child. If secondaryBackground is also specified then this widget only appears when the child has been dragged down or to the right.
behavior HitTestBehavior
How to behave during hit tests.
child Widget
The widget below this widget in the tree.
confirmDismiss ConfirmDismissCallback?
Gives the app an opportunity to confirm or veto a pending dismissal.
crossAxisEndOffset double
Defines the end offset across the main axis after the card is dismissed.
direction DismissDirection
The direction in which the widget can be dismissed.
dismissThresholds Map<DismissDirection, double>
The offset threshold the item has to be dragged in order to be considered dismissed.
dragStartBehavior DragStartBehavior
Determines the way that drag start behavior is handled.
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
movementDuration Duration
Defines the duration for card to dismiss or to come back to original position if not dismissed.
onDismissed DismissDirectionCallback?
Called when the widget has been dismissed, after finishing resizing.
onResize VoidCallback?
Called when the widget changes size (i.e., when contracting before being dismissed).
onUpdate DismissUpdateCallback?
Called when the dismissible widget has been dragged.
resizeDuration Duration?
The amount of time the widget will spend contracting before onDismissed is called.
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secondaryBackground Widget?
A widget that is stacked behind the child and is exposed when the child has been dragged up or to the left. It may only be specified when background has also been specified.


createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
createState() State<Dismissible>
Creates the mutable state for this widget at a given location in the tree.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
toStringShort() String
A short, textual description of this widget.


operator ==(Object other) bool
The equality operator.