Skip to content

Conversation

GeekTree0101
Copy link

Description

Adds a scrollToTop() method to ScrollOffsetController.

This method allows users to easily animate the scroll position to the top of the list without needing to manually specify offset = 0.0. It improves code readability and provides a convenient abstraction for a common use case.

Before:

// N/A

After:

await scrollOffsetController.animateScroll(
  offset: -scrollOffsetController.currentScrollOffset,
  duration: Duration(milliseconds: 300),
);

Example

await scrollOffsetController.scrollToTop(duration: Duration(milliseconds: 300));

This PR introduces no breaking changes and simply wraps the existing animateScroll API with a helper method.

Related Issues

N/A

Checklist

  • I signed the CLA.
  • All tests from running flutter test pass.
  • flutter analyze does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Copy link

google-cla bot commented Aug 28, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant