jumpToHeader method
Jumps the scroll position of an axis
from its current value to the
corresponding value of a header in the index index
.
See also:
- animateToHeader scroll to a header position with an animation.
- jumpToCoordinate make a coordinate visible
- ScrollController.jumpTo the corresponding built int to flutter scroll mechanism.
Implementation
void jumpToHeader(int index, Axis axis) {
if (!isAttached) {
return;
}
final scrollController = getScrollControllerFor(axis: axis)!;
// Get the pixel offset of this header necessary to make it visible.
final jumpOffset = _getOffsetToHeader(index, axis, scrollController);
// If there is no jump offset, don't scroll
if (jumpOffset == null) {
return;
}
// Finally, apply offset
scrollController.jumpTo(jumpOffset);
}