jumpToIndexAndOffset method
Jumps the origin-index to the given index
, and the scroll-position to offset
,
without animation, and without checking if the new value is in range.
Any active animation is canceled. If the user is currently scrolling, that action is canceled.
Implementation
void jumpToIndexAndOffset({required int index, required double offset}) {
// If we didn't change the origin-index, go to its offset position.
if (_originIndex == index) {
super.jumpTo(offset);
}
// If we changed the origin, go to its offset position.
else {
_originIndex = index;
_initialScrollOffset = offset;
// Notify is enough. The key will change,
// and the offset will revert to _initialScrollOffset),
notifyListeners();
}
}