startAutoScrollIfNecessary method

void startAutoScrollIfNecessary(
  1. Rect dragTarget
)

Starts the auto scroll if the dragTarget is close to the edge.

The scroll starts to scroll the scrollable if the target rect is close to the edge of the scrollable; otherwise, it remains stationary.

If the scrollable is already scrolling, calling this method updates the previous dragTarget to the new value and continues scrolling if necessary.

Implementation

void startAutoScrollIfNecessary(Rect dragTarget) {
  final Offset deltaToOrigin = scrollable.deltaToScrollOrigin;
  _dragTargetRelatedToScrollOrigin = dragTarget.translate(deltaToOrigin.dx, deltaToOrigin.dy);
  if (_scrolling) {
    // The change will be picked up in the next scroll.
    return;
  }
  assert(!_scrolling);
  _scroll();
}