Skip to content

Commit 2a230d1

Browse files
authored
Clarify CustomScrollView use cases (#189692)
<!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> This updates the `CustomScrollView` API documentation to describe its common use case more directly: combining different kinds of scrollable content. The introduction now also calls out `SliverToBoxAdapter`, so readers can see how regular box widgets fit alongside lists, grids, and expanding headers. Fixes #142673. Tests: not run (documentation-only change; comment-only changes are automatically test-exempt). ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 59c14b6 commit 2a230d1

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎packages/flutter/lib/src/widgets/scroll_view.dart‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -587,13 +587,15 @@ abstract class ScrollView extends StatelessWidget {
587587
}
588588
}
589589

590-
/// A [ScrollView] that creates custom scroll effects using [slivers].
591-
///
592-
/// A [CustomScrollView] lets you supply [slivers] directly to create various
593-
/// scrolling effects, such as lists, grids, and expanding headers. For example,
594-
/// to create a scroll view that contains an expanding app bar followed by a
595-
/// list and a grid, use a list of three slivers: [SliverAppBar], [SliverList],
596-
/// and [SliverGrid].
590+
/// A [ScrollView] that combines multiple [slivers] in one scrollable view.
591+
///
592+
/// A [CustomScrollView] lets you combine lists, grids, and other widgets in a
593+
/// single scrollable view by supplying [slivers] directly. Slivers can
594+
/// represent lists, grids, and expanding headers. Widgets that use the box
595+
/// layout model can be included using a [SliverToBoxAdapter]. For example, to
596+
/// create a scroll view that contains an expanding app bar followed by a list
597+
/// and a grid, use a list of three slivers: [SliverAppBar], [SliverList], and
598+
/// [SliverGrid].
597599
///
598600
/// [Widget]s in these [slivers] must produce [RenderSliver] objects.
599601
///
@@ -716,7 +718,8 @@ abstract class ScrollView extends StatelessWidget {
716718
/// * [IndexedSemantics], which allows annotating child lists with an index
717719
/// for scroll announcements.
718720
class CustomScrollView extends ScrollView {
719-
/// Creates a [ScrollView] that creates custom scroll effects using slivers.
721+
/// Creates a [ScrollView] that combines multiple slivers in one scrollable
722+
/// view.
720723
///
721724
/// See the [ScrollView] constructor for more details on these arguments.
722725
const CustomScrollView({

0 commit comments

Comments
 (0)