Skip to main content

scroll_drag_detector 1.0.0-dev.3 copy "scroll_drag_detector: ^1.0.0-dev.3" to clipboard
scroll_drag_detector: ^1.0.0-dev.3 copied to clipboard

A drag gesture detector that can deal with scroll views inside of it.

Scroll Drag Detector #

Pub Version Coverage lintervention_badge Bluesky

A special version of GestureDetector that picks up overscrolling ScrollViews inside of it.

Unlocks easy draggable scrollable sheets in Flutter.

Installation 💻 #

❗ In order to start using Scroll Drag Detector you must have the Dart SDK installed on your machine.

Or install via dart pub:

dart pub add scroll_drag_detector

Usage #

Choose how movement in each physical direction is routed:

ScrollDragDetector(
  up: ScrollDragMode.dragFirst,
  down: ScrollDragMode.boundaryStart,
  left: ScrollDragMode.none,
  right: ScrollDragMode.none,
  onVerticalDragUpdate: (details, wouldScroll) {
    // Move the surrounding draggable.
  },
  child: scrollable,
)

Use ScrollDragMode.scrollFirst to let the child reach its boundary before the surrounding draggable takes over. Use ScrollDragDetector.legacy to migrate the previous scrollableCanMoveBack and onlyDragWhenScrollWasAtTop configuration without changing conventional sheet behavior.

Overriding child scroll behavior #

When a child overrides its scroll behavior, wrap it in ScrollDragBehavior so the detector can still stop scrolling during a drag:

ScrollConfiguration(
  behavior: ScrollDragBehavior(
    parent: const ScrollBehavior().copyWith(scrollbars: false),
  ),
  child: ListView.builder(itemBuilder: buildItem),
)

The wrapper also works with per-view overrides such as CustomScrollView(scrollBehavior: ScrollDragBehavior(parent: customBehavior)). It preserves the consumer's settings, including copyWith(...) overrides, and delegates unchanged when there is no ancestor detector.


10
likes
140
points
8.64k
downloads

Documentation

API reference

Publisher

verified publisherwhynotmake.it

Weekly Downloads

A drag gesture detector that can deal with scroll views inside of it.

Homepage
Repository (GitHub)
View/report issues

Topics

#animation #motion #physics #spring #curve

License

MIT (license)

Dependencies

flutter, meta

More

Packages that depend on scroll_drag_detector