cacheExtent property Null safety
The viewport has an area before and after the visible area to cache items that are about to become visible when the user scrolls.
Items that fall in this cache area are laid out even though they are not (yet) visible on screen. The cacheExtent describes how many pixels the cache area extends before the leading edge and after the trailing edge of the viewport.
The total extent, which the viewport will try to cover with children, is cacheExtent before the leading edge + extent of the main axis + cacheExtent after the trailing edge.
The cache area is also used to implement implicit accessibility scrolling on iOS: When the accessibility focus moves from an item in the visible viewport to an invisible item in the cache area, the framework will bring that item into view with an (implicit) scroll action.
The getter can never return null, but the field is nullable because the setter can be set to null to reset the value to RenderAbstractViewport.defaultCacheExtent (in which case cacheExtentStyle must be CacheExtentStyle.pixel).
See also:
- cacheExtentStyle, which controls the units of the cacheExtent.
Implementation
double? get cacheExtent => _cacheExtent;
Implementation
set cacheExtent(double? value) {
value ??= RenderAbstractViewport.defaultCacheExtent;
assert(value != null);
if (value == _cacheExtent) {
return;
}
_cacheExtent = value;
markNeedsLayout();
}