Skip to content

Commit

Permalink
scroll_positioned_list - add animateScrollAbsolute
Browse files Browse the repository at this point in the history
  • Loading branch information
vesuvi88 committed Feb 27, 2025
1 parent 35cabb1 commit 7ce518d
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,25 +287,36 @@ class ScrollOffsetController {
{required double offset,
required Duration duration,
Curve curve = Curves.linear}) async {
final currentPosition =
_scrollableListState!.primary.scrollController.offset;
final currentPosition =
scrollableListState!.primary.scrollController.offset;
final newPosition = currentPosition + offset;
await _scrollableListState!.primary.scrollController.animateTo(
await scrollableListState!.primary.scrollController.animateTo(
newPosition,
duration: duration,
curve: curve,
);
}

_ScrollablePositionedListState? _scrollableListState;
Future<void> animateScrollAbsolute(
{required double offset,
required Duration duration,
Curve curve = Curves.linear}) async {
await scrollableListState!.primary.scrollController.animateTo(
offset,
duration: duration,
curve: curve,
);
}

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

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

void _detach() {
_scrollableListState = null;
scrollableListState = null;
}
}

Expand Down

0 comments on commit 7ce518d

Please sign in to comment.