Slidable.builder constructor

const Slidable.builder({
  1. Key? key,
  2. required Widget child,
  3. required Widget actionPane,
  4. SlideActionDelegate? actionDelegate,
  5. SlideActionDelegate? secondaryActionDelegate,
  6. double showAllActionsThreshold = 0.5,
  7. double actionExtentRatio = _kActionsExtentRatio,
  8. Duration movementDuration = _kMovementDuration,
  9. Axis direction = Axis.horizontal,
  10. bool closeOnScroll = true,
  11. bool enabled = true,
  12. SlidableDismissal? dismissal,
  13. SlidableController? controller,
  14. double? fastThreshold,
})

Creates a widget that can be slid.

The actionDelegate is a delegate that builds the slide actions that appears when the child has been dragged down or to the right. The secondaryActionDelegate is a delegate that builds the slide actions that appears when the child has been dragged up or to the left.

The delegate, closeOnScroll and enabled arguments must not be null. The actionExtentRatio and showAllActionsThreshold arguments must be greater or equal than 0 and less or equal than 1.

The key argument must not be null if the slideToDismissDelegate is provided because Slidables 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 Slidable.builder({
  Key? key,
  required this.child,
  required this.actionPane,
  this.actionDelegate,
  this.secondaryActionDelegate,
  this.showAllActionsThreshold = 0.5,
  this.actionExtentRatio = _kActionsExtentRatio,
  this.movementDuration = _kMovementDuration,
  this.direction = Axis.horizontal,
  this.closeOnScroll = true,
  this.enabled = true,
  this.dismissal,
  this.controller,
  double? fastThreshold,
})  : assert(showAllActionsThreshold >= .0 && showAllActionsThreshold <= 1.0,
          'showAllActionsThreshold must be between 0.0 and 1.0'),
      assert(actionExtentRatio >= .0 && actionExtentRatio <= 1.0,
          'actionExtentRatio must be between 0.0 and 1.0'),
      assert(dismissal == null || key != null,
          'a key must be provided if slideToDismissDelegate is set'),
      assert(fastThreshold == null || fastThreshold >= .0,
          'fastThreshold must be positive'),
      fastThreshold = fastThreshold ?? _kFastThreshold,
      super(key: key);