Repository navigation
Closed
Labels
f: scrollingViewports, list views, slivers, etc.found in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: duplicateIssue is closed as a duplicate of an existing issue
Description
Steps to Reproduce
This repo is a reproduce of the error :Repo
clone the repo and run the app
Expected results:
So what I'm trying to do is to scroll automatically using ScrollController.animateTo() but when the animation is still not finished if you try to scroll by holing and dragging the scrollView this error will appear.
════════ Exception caught by gesture ═══════════════════════════════════════════
The following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 659 pos 12: '_hold == null': is not true.
as long as I walk through it its seems to be a bug in flutter
it caused by this
void _handleDragStart(DragStartDetails details) {
// It's possible for _hold to become null between _handleDragDown and
// _handleDragStart, for example if some user code calls jumpTo or otherwise
// triggers a new activity to begin.
assert(_drag == null);
_drag = position.drag(details, _disposeDrag);
assert(_drag != null);
this line -> assert(_hold == null);
}
After investigating I find that hardcode _hold=null in _handleDragStart will fix this issue with no visible side effects.
Summary
- using ScrollController.animateTo() to scroll and hold while scrolling will trigger the error.
_holdis not always null soassert(_hold == null)is not true.- error can be avoided if you set
_hold=nullin_handleDragStartinstead of assert that it null.
Details
════════ Exception caught by gesture ═══════════════════════════════════════════
The following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 641 pos 12: '_hold == null': is not true.
2
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md
When the exception was thrown, this was the stack
#2 ScrollableState._handleDragStart
package:flutter/…/widgets/scrollable.dart:641
#3 DragGestureRecognizer._checkStart.<anonymous closure>
package:flutter/…/gestures/monodrag.dart:429
#4 GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:193
#5 DragGestureRecognizer._checkStart
package:flutter/…/gestures/monodrag.dart:429
#6 DragGestureRecognizer.acceptGesture
package:flutter/…/gestures/monodrag.dart:349
#7 GestureArenaManager._resolveByDefault
package:flutter/…/gestures/arena.dart:251
#8 GestureArenaManager._tryToResolveArena.<anonymous closure>
package:flutter/…/gestures/arena.dart:232
(elided 12 frames from class _AssertionError and dart:async)
Handler: "onStart"
Recognizer: VerticalDragGestureRecognizer#5d9a3
start behavior: start
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by gesture ═══════════════════════════════════════════
'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 646 pos 12: '_hold == null || _drag == null': is not true.
════════════════════════════════════════════════════════════════════════════════
Analyzing bug...
No issues found! (ran in 3.8s)
[√] Flutter (Channel stable, 2.5.2, on Microsoft Windows [Version 10.0.19043.1237], locale en-US)
• Flutter version 2.5.2 at F:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 3595343e20 (2 days ago), 2021-09-30 12:58:18 -0700
• Engine revision 6ac856380f
• Dart version 2.14.3
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at F:\DEV\androidSDK
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[√] IntelliJ IDEA Ultimate Edition (version 2021.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.1
• Flutter plugin version 60.1.3
• Dart plugin version 211.7727
[√] IntelliJ IDEA Ultimate Edition (version 2021.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2020.1
• Flutter plugin version 59.0.4
• Dart plugin version 212.5080.8
[√] VS Code (version 1.60.2)
• VS Code at C:\Users\aymen\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.26.0
[√] Connected device (3 available)
• CPH2083 (mobile) • 6HMNQOSW7DHISSSK • android-arm64 • Android 9 (API 28)
• Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.61
• Edge (web) • edge • web-javascript • Microsoft Edge 94.0.992.38
! Doctor found issues in 2 categories.
Metadata
Metadata
Assignees
Labels
f: scrollingViewports, list views, slivers, etc.found in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: duplicateIssue is closed as a duplicate of an existing issue
Activity
maheshj01 commentedon Oct 4, 2021
Hi @Danzo7, Thanks for filing the issue. I can reproduce the issue on the stable 2.5.1 and the master
2.6.0-12.0.pre.165channel, when the animation is happening or when it completes if you drag the list the exception is thrown. The issue seems to be withisScrollingNotifierreproducible code
flutter doctor -v
logs
@Danzo7 if you are trying to automatically scroll based on users' scroll direction you may try this and you can interrupt the scroll animation too.
Danzo7 commentedon Oct 6, 2021
Hi @maheshmnj Thanks for your suggestion but in my case this is not going to work for a reason which is why I'm using "isScrollingNotifier.addListener()" in first place.
So what I'm actually trying to do is making a snap effect when a user stop scrolling at a certain pixel. So what I need is to check whether
wheel.position.isScrollingNotifier.valuevalue istrueorfalseso It look like this:I first use
position.addListener()but it was not enough for such a thing asposition.isScrollingNotifier.valueis alwaystrueinside theposition.addListener(), I also try to useposition.userScrollDirectioninstead and compare it toScrollDirection.idlebut unfortunately the event stops immediately when u stop scrolling just beforeposition.userScrollDirectionis equal toScrollDirection.idleso it will never be. This is why I useposition.isScrollingNotifieraddListener()instead.setting
_hold=nulllike I said will fix the issue and seems to have no impact (its already should be null).You could try it yourself
src/widgets/scrollable.dartline:652:I'm sure this bug happen because there is an unfinished scroll animation and a user scroll activity at the same time, Making
_hold=nullwill allow to fresh start the user scroll activity(cancel the animation).Also according to the
scroll_controller.dartline 158-169animate/jumpTo should be indeed canceled in case of user interruption:goderbauer commentedon Oct 6, 2021
Duplicate of #14452.
github-actions commentedon Oct 21, 2021
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.