Repository navigation
NestedScrollView scrolls inner view without scrolling outer view #136199
Description
Activity
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Oct 10, 2023 Thanks for the report. Reproduced this on master channel as well.
I think the actual behavior/result is:
The outer view gets scrolled but gets "restored" to the old position when flicking the list.flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.13.6, on macOS 14.0 23A344 darwin-x64, locale en-VN) • Flutter version 3.13.6 on channel stable at /Users/huynq/Documents/GitHub/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ead455963c (5 days ago), 2023-09-26 18:28:17 -0700 • Engine revision a794cf2681 • Dart version 3.1.3 • DevTools version 2.25.0 [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-34, build-tools 32.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio Giraffe.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A240d • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.3) • Android Studio at /Applications/Android Studio Giraffe.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) [✓] Android Studio (version 2022.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.82.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.72.0 [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-x64 • macOS 14.0 23A344 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 117.0.5938.132 [✓] Network resources • All expected network resources are available. • No issues found![!] Flutter (Channel master, 3.16.0-8.0.pre.15, on macOS 14.0 23A344 darwin-x64, locale en-VN) • Flutter version 3.16.0-8.0.pre.15 on channel master at /Users/huynq/Documents/GitHub/flutter_master ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 0194d93665 (45 minutes ago), 2023-10-09 21:58:28 -0400 • Engine revision 92880e9847 • Dart version 3.3.0 (build 3.3.0-3.0.dev) • DevTools version 2.28.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-34, build-tools 32.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio Giraffe.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A240d • CocoaPods version 1.13.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.3) • Android Studio at /Applications/Android Studio Giraffe.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) [✓] Android Studio (version 2022.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.82.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.74.0 [✓] Connected device (3 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 11 (API 30) • macOS (desktop) • macos • darwin-x64 • macOS 14.0 23A344 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 117.0.5938.149 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category.
Reacted by Rory Stephenson- addedframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16and removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Oct 10, 2023 cc @Piinks as I noticed you have been aggregating the various NestedScrollView issues.
- addedP2Important issues not at the top of the work listImportant issues not at the top of the work listtriaged-frameworkTriaged by Framework teamTriaged by Framework team
on Oct 10, 2023 Adding a +1 to this.
I have another sample that reproduces this.
When I remove the
SliverOverlapInjectorit makes it more difficult to reproduce, but it is still possible. And only withBouncingScrollPhysics.Edit: Minimizing the sample.
class NestedScrollViewExampleApp extends StatelessWidget { const NestedScrollViewExampleApp({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: NestedScrollView( headerSliverBuilder: (context, innerBoxIsScrolled) => [ SliverToBoxAdapter( child: Container(color: Colors.green, height: 300), ), SliverOverlapAbsorber( handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), sliver: SliverToBoxAdapter( child: Container( color: Colors.blue, height: 64, ), ), ), ], body: SingleChildScrollView( child: Container( decoration: gradient(), height: 800, ), ), ), ); } BoxDecoration gradient() { return const BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [Colors.black, Colors.blue], stops: [0, 1], ), ); } }
I have a video as well, I am repeating swipe up swipe down motion repeatedly my finger leaves the screen each time.
swiping.mp4
While testing that I also came across this behavior, after flinging, but not quite till the top of the outer scrollable, the inner scrollable still performs "bounce" The first fling is bad, ignore that, but the subsequent ones show the issue. The white background should not be visible imo. The second fling up presented the original issue.
residual_scroll.mp4
I think I found it:
We want to go to the underlined if statement, but the inner position is not fully setteled? yet; or there is a rounding error when the spring animation is finishing; or the spring animation finishes but does not properly set the inner scroll position to 0 but rather keeps the spring's animation final position, which may overshoot the 0? All these are guesses.
Edit: this turned out to be incorrect as the underlined condition is in an 'else' branch that would be unreachable if the value
== 0.So for anyone wanting a quick dirty fix, throw this at the beginning of _getMetrics()
if (innerPosition.pixels <= precisionErrorTolerance && innerPosition.pixels >= -precisionErrorTolerance) { innerPosition.correctPixels(0.0); }
It just hides the underlying issue, which I am now committed to finding and fixing, once I figure out how to set up a dev env for Flutter that is :)
- added a commit that references this issue
on Jan 10, 2024 - addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on Jan 10, 2024 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Jan 24, 2024



Is there an existing issue for this?
Steps to reproduce
Example reproduction for Android:
Expected results
When flicking up the inner scroll content should first scroll back to it's zero scroll position, then the outer scroll view should scroll to its maximum scroll position before the inner scroll view starts scrolling.
Actual results
The inner scroll view is scrolled without the outer scroll view getting scrolled. When I then subsequently scroll a little further down the outer scroll view gets scrolled and then the inner scroll view continues scrolling.
Code sample
Note the code sample could potentially me more minimal but I preferred to start from the example code and make the minimal changes necessary to reproduce.
Code sample
Screenshots or Video
Screenshots / Video demonstration
23-10-09-15-06-48.mp4
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output