Dismissible constructor

const Dismissible({
  1. required Key key,
  2. required Widget child,
  3. Widget? background,
  4. Widget? secondaryBackground,
  5. ConfirmDismissCallback? confirmDismiss,
  6. VoidCallback? onResize,
  7. DismissUpdateCallback? onUpdate,
  8. DismissDirectionCallback? onDismissed,
  9. DismissDirection direction = DismissDirection.horizontal,
  10. Duration? resizeDuration = const Duration(milliseconds: 300),
  11. Map<DismissDirection, double> dismissThresholds = const <DismissDirection, double>{},
  12. Duration movementDuration = const Duration(milliseconds: 200),
  13. double crossAxisEndOffset = 0.0,
  14. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  15. HitTestBehavior behavior = HitTestBehavior.opaque,
})

Creates a widget that can be dismissed.

The key argument is required because Dismissibles are commonly used in lists and removed from the list when dismissed. Without keys, the default behavior is to sync widgets based on their index in the list, which means the item after the dismissed item would be synced with the state of the dismissed item. Using keys causes the widgets to sync according to their keys and avoids this pitfall.

Implementation

const Dismissible({
  required Key super.key,
  required this.child,
  this.background,
  this.secondaryBackground,
  this.confirmDismiss,
  this.onResize,
  this.onUpdate,
  this.onDismissed,
  this.direction = DismissDirection.horizontal,
  this.resizeDuration = const Duration(milliseconds: 300),
  this.dismissThresholds = const <DismissDirection, double>{},
  this.movementDuration = const Duration(milliseconds: 200),
  this.crossAxisEndOffset = 0.0,
  this.dragStartBehavior = DragStartBehavior.start,
  this.behavior = HitTestBehavior.opaque,
}) : assert(secondaryBackground == null || background != null);