-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
ScrollPhysics currently has hard-coded single view assumptions in two places, see the WidgetsBinding.instance.window in the snippet below:
flutter/packages/flutter/lib/src/widgets/scroll_physics.dart
Lines 386 to 391 in d1244b7
| 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 | |
| ); |
flutter/packages/flutter/lib/src/widgets/scroll_physics.dart
Lines 249 to 258 in d1244b7
| 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
Labels
f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Type
Projects
Status
Done