sample method
Converts globalPointer into every coordinate the drag pipeline
needs, or null when the scrollable is unmounted (or its viewport
box is detached mid-teardown).
Implementation
PointerSample? sample(Offset globalPointer) {
if (!_scrollable.mounted) {
return null;
}
final box = _scrollable.context.findRenderObject();
if (box is! RenderBox || !box.attached) {
return null;
}
final local = box.globalToLocal(globalPointer);
return (
sliverX: local.dx,
sliverY:
_scrollable.position.pixels +
local.dy -
_renderPort.precedingScrollExtent,
viewportDy: local.dy,
viewportHeight: box.size.height,
);
}