Deprecated cacheExtent and cacheExtentStyle
The `cacheExtent` and `cacheExtentStyle` properties are deprecated. They are replaced by `scrollCacheExtent` with a `ScrollCacheExtent` object.
Summary
#
Flutter 3.44 deprecates cacheExtent and cacheExtentStyle
in scrolling-related widgets, such as
ListView, GridView, CustomScrollView, and Viewport,
and their corresponding render objects, such as RenderViewport.
The new scrollCacheExtent property encapsulates
both the value and the caching strategy (pixels or viewport).
Background
#
Previously, cacheExtent was a double and
cacheExtentStyle determined how that double was interpreted
(either as pixels or as a fraction of the viewport).
This split made the setting harder to understand.
The new scrollCacheExtent property uses a ScrollCacheExtent object that
explicitly encapsulates both the value and
the caching strategy (pixels or viewport),
which provides type safety and clearer intent.
Migration guide
#Widget layer
#cacheExtent (pixels)
#
If your code uses cacheExtent,
which defaults to pixels,
use scrollCacheExtent with ScrollCacheExtent.pixels.
Before:
ListView(
cacheExtent: 500.0,
children: // ...
)
After:
ListView(
scrollCacheExtent: const ScrollCacheExtent.pixels(500.0),
children: // ...
)
cacheExtentStyle (viewport)
#
If your code uses cacheExtent with CacheExtentStyle.viewport,
which is common in Viewport,
use scrollCacheExtent with ScrollCacheExtent.viewport.
Before:
Viewport(
cacheExtent: 0.5,
cacheExtentStyle: CacheExtentStyle.viewport,
slivers: // ...
)
After:
Viewport(
scrollCacheExtent: const ScrollCacheExtent.viewport(0.5),
slivers: // ...
)
Render object layer
#
If your code manually sets properties on
RenderViewport or a similar render object,
use scrollCacheExtent.
Before:
renderViewport.cacheExtent = 500.0;
renderViewport.cacheExtentStyle = CacheExtentStyle.pixel;
After:
renderViewport.scrollCacheExtent = const ScrollCacheExtent.pixels(500.0);
Timeline
#
Landed in version: 3.41.0-0.0.pre
In stable release: 3.44
References
#API documentation:
Relevant PRs:
除非另有说明,本文档之所提及适用于 Flutter 3.44.0 版本。本页面最后更新时间:2026-05-20。查看文档源码 或者 为本页面内容提出建议。