Skip to content

Commit d10e4c9

Browse files
authored
Updates scroll cache extent doc (flutter#184142)
<!-- 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 --> as title ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] 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]. **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 e79bf6c commit d10e4c9

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

packages/flutter/lib/src/rendering/viewport.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ import 'object.dart';
2323
import 'sliver.dart';
2424
import 'viewport_offset.dart';
2525

26-
/// The amount of additional content to cache around the viewport.
26+
/// The amount of additional content to display and lay out around the viewport.
27+
///
28+
/// The cache area is used to lay out slivers before they are visible on screen.
29+
/// Items that fall in this cache area are laid out even though they are not
30+
/// visible on screen. This allows the viewport to render them ahead of time,
31+
/// enabling a smoother scrolling experience as items scroll into view.
32+
///
33+
/// This class encapsulates both the value and the style of the cache extent.
34+
/// It allows the cache extent to be defined either as a fixed number of logical
35+
/// pixels using [ScrollCacheExtent.pixels] or as a multiplier of the viewport's
36+
/// main axis extent using [ScrollCacheExtent.viewport].
2737
///
2838
/// See also:
2939
///
@@ -36,6 +46,12 @@ sealed class ScrollCacheExtent {
3646
const factory ScrollCacheExtent.pixels(double pixels) = _PixelScrollCacheExtent;
3747

3848
/// Creates a cache extent as a multiplier of the viewport's main axis extent.
49+
///
50+
/// The main axis extent is the size of the viewport in its main axis. For
51+
/// example, for a vertically scrolling list, the main axis extent is the
52+
/// height of the viewport. If the viewport is 600 logical pixels tall, then
53+
/// `ScrollCacheExtent.viewport(2.0)` results in a cache extent of 1200 logical
54+
/// pixels.
3955
const factory ScrollCacheExtent.viewport(double value) = _ViewportScrollCacheExtent;
4056

4157
/// Returns the cache extent in logical pixels for a given [mainAxisExtent].

0 commit comments

Comments
 (0)