Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,15 @@ class ScrollablePositionedList extends StatefulWidget {
class ItemScrollController {
/// Whether any ScrollablePositionedList objects are attached this object.
///
/// If `false`, then [jumpTo] and [scrollTo] must not be called.
/// If `false`, then [jumpTo], [scrollTo] and [jumpToPixel] must not be called.
bool get isAttached => _scrollableListState != null;

/// Returns the current [scrollController.offset].
/// Also see [jumpToPixel].
double get currentScrollControllerOffset {
return _scrollableListState!.primary.scrollController.offset;
}

_ScrollablePositionedListState? _scrollableListState;

/// Immediately, without animation, reconfigure the list so that the item at
Expand Down Expand Up @@ -245,6 +251,23 @@ class ItemScrollController {
);
}

/// Immediately jump the list to the provided [value] via [scrollController.jumpTo].
/// Also see [currentScrollControllerOffset].
void jumpToPixel(double value) {
_scrollableListState!.primary.scrollController.jumpTo(value);
}

/// Calls [primary.scrollController.animateTo] with the given values.
/// See [currentScrollControllerOffset] to get the current offset.
void scrollToPixel({
required double offset,
required Duration duration,
required Curve curve,
}) {
_scrollableListState!.primary.scrollController
.animateTo(offset, duration: duration, curve: curve);
}

void _attach(_ScrollablePositionedListState scrollableListState) {
assert(_scrollableListState == null);
_scrollableListState = scrollableListState;
Expand Down