Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove hard-coded single-view assumption from ScrollPhysics #117478

Closed
@goderbauer

Description

@goderbauer

ScrollPhysics currently has hard-coded single view assumptions in two places, see the WidgetsBinding.instance.window in the snippet below:

static final Tolerance _kDefaultTolerance = Tolerance(
// TODO(ianh): Handle the case of the device pixel ratio changing.
// TODO(ianh): Get this from the local MediaQuery not dart:ui's window object.
velocity: 1.0 / (0.050 * WidgetsBinding.instance.window.devicePixelRatio), // logical pixels per second
distance: 1.0 / WidgetsBinding.instance.window.devicePixelRatio, // logical pixels
);

bool recommendDeferredLoading(double velocity, ScrollMetrics metrics, BuildContext context) {
assert(velocity != null);
assert(metrics != null);
assert(context != null);
if (parent == null) {
final double maxPhysicalPixels = WidgetsBinding.instance.window.physicalSize.longestSide;
return velocity.abs() > maxPhysicalPixels;
}
return parent!.recommendDeferredLoading(velocity, metrics, context);
}

In a multi-viewed world, this will not work anymore because the ScrollPhysics have no idea what view/window the scrollable they control is in. We need to refactor this, i.e. either the ScrollPhysics somehow need to look up the current view via View.of(context) or the relevant information need to be passed in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions