dispatchScroll method

Future<void> dispatchScroll(
  1. double x,
  2. double y,
  3. double dy,
  4. double dx,
)

Scroll by dy logical pixels (positive scrolls down) at (x, y).

A pointer scroll, not a scrollable's controller: the surface under the cursor is whatever the document put there, and driving a controller would require knowing which one — which is exactly what a caller inspecting an unfamiliar screen does not know.

Implementation

Future<void> dispatchScroll(double x, double y, double dy, double dx) async {
  final binding = WidgetsBinding.instance;
  final position = Offset(x, y);
  binding.handlePointerEvent(PointerHoverEvent(position: position));
  binding.handlePointerEvent(PointerScrollEvent(
    position: position,
    scrollDelta: Offset(dx, dy),
  ));
  await binding.endOfFrame;
}