-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
I have a complex ListView with approximately 300 rows, and scrolling is demonstrating too much friction compared to a native list view on iOS. After some debugging, I figured out that it's because of this line in scroll_physics.dart:
| velocity: velocity * 0.91, // TODO(abarth): We should move this constant closer to the drag end. |
The createBallisticSimulation method seems to get called several times per second during the ballistic part of scroll movements on my ListView, which I think is because the ScrollMetrics.maxScrollExtent property is changing slightly as Flutter discovers the rendered sizes of the widgets as they scroll into the viewport. However, each time it gets called, the velocity gets scaled down by 0.91, which effectively adds a lot of additional friction to the otherwise quite smooth BouncingScrollSimulation.
I've worked around the issue by making my own ScrollPhysics class which changes the constant to 1.0 (i.e. no multiplication), and it works great, but it would be nice to have it fixed in the framework.
@override
Simulation createBallisticSimulation(ScrollMetrics position, double velocity) {
final Tolerance tolerance = this.tolerance;
if (velocity.abs() >= tolerance.velocity || position.outOfRange) {
return BouncingScrollSimulation(
spring: spring,
position: position.pixels,
velocity: velocity * 0.91, // TODO(abarth): We should move this constant closer to the drag end.
leadingExtent: position.minScrollExtent,
trailingExtent: position.maxScrollExtent,
tolerance: tolerance,
);
}
return null;
}
Steps to Reproduce
Scroll any reasonably complex ListView on iOS and observe that the physics
seem to be excessively damped compared to native iOS list views.
[✓] Flutter (Channel master, v1.5.9-pre.193, on Mac OS X 10.14.4 18E226, locale en-US)
• Flutter version 1.5.9-pre.193 at /Users/mil/flutter
• Framework revision 3a6acb8c25 (8 hours ago), 2019-05-09 09:23:30 -0700
• Engine revision 644db5a49c
• Dart version 2.3.1 (build 2.3.1-dev.0.0 a0290f823c)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/mil/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• ios-deploy 1.9.4
• CocoaPods version 1.6.0
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 35.2.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[✓] IntelliJ IDEA Community Edition (version 2019.1.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 35.3.3
• Dart plugin version 191.7141.49
[✓] VS Code (version 1.33.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.26.0