recommendDeferredLoadingForContext method Null safety

bool recommendDeferredLoadingForContext(
  1. BuildContext context

Provides a heuristic to determine if expensive frame-bound tasks should be deferred for the context at a specific point in time.

Calling this method does not create a dependency on any other widget. This also means that the value returned is only good for the point in time when it is called, and callers will not get updated if the value changes.

The heuristic used is determined by the physics of this Scrollable via ScrollPhysics.recommendDeferredLoading. That method is called with the current ScrollPosition.activity's ScrollActivity.velocity.

If there is no Scrollable in the widget tree above the context, this method returns false.


static bool recommendDeferredLoadingForContext(BuildContext context) {
  final _ScrollableScope? widget = context.getElementForInheritedWidgetOfExactType<_ScrollableScope>()?.widget as _ScrollableScope?;
  if (widget == null) {
    return false;
  return widget.position.recommendDeferredLoading(context);