DragSelectableProvider class
State management provider for drag-selectable list functionality.
This provider manages all aspects of drag selection state including:
- Current selection state for all list items
- Drag selection mode activation and deactivation
- Scroll controller for the associated ListView
- Initial selection state for range selection operations
Architecture
The provider extends ChangeNotifier to integrate with Flutter's state management system and uses the Provider package for dependency injection. It's designed to work with DragSelectableListView but can be used independently for custom implementations.
Selection Model
The provider maintains two key selection states:
- Current Selection (
_selected): Real-time selection state of all items - Initial Selection (initialSelected): Baseline state when drag starts
Range selection operations toggle items relative to the initial state, allowing intuitive multi-selection regardless of prior selection states.
- Mixed-in types
Constructors
-
DragSelectableProvider(List<
bool> _selected) - Creates a new drag selectable provider with the specified initial selection state.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
initialSelected
↔ List<
bool> -
The selection state when drag selection mode was activated.
getter/setter pair
- isSelecting → bool
-
Whether drag selection mode is currently active.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollController → ScrollController
-
Controller for the ListView's scroll behavior.
final
-
selected
→ List<
bool> -
Current selection state for all list items.
no setter
- startIndex ↔ int?
-
The list item index where drag selection was initiated.
getter/setter pair
- startPositionY ↔ double
-
The initial Y coordinate of a pointer interaction.
getter/setter pair
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Disposes of all resources used by this provider.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toggle(
int index, bool value) → void - Toggles the selection state of a specific item.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateInitialSelected(
List< bool> selection) → void - Updates the baseline selection state for drag selection operations.
-
updateIsSelecting(
bool state) → void - Updates the drag selection mode state.
-
updateSelected(
List< bool> newSelection, bool enableHapticFeedback) → void - Updates the selection state for multiple items in a batch operation.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited