Slidable.builder constructor
- Key? key,
- required Widget child,
- required Widget actionPane,
- SlideActionDelegate? actionDelegate,
- SlideActionDelegate? secondaryActionDelegate,
- double showAllActionsThreshold = 0.5,
- double actionExtentRatio = _kActionsExtentRatio,
- Duration movementDuration = _kMovementDuration,
- Axis direction = Axis.horizontal,
- bool closeOnScroll = true,
- bool enabled = true,
- SlidableDismissal? dismissal,
- SlidableController? controller,
- 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);