Skip to content

Failed assertion: line 659 pos 12: '_hold == null': is not true.  #91166

Closed

Description

@Danzo7

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.
  • _hold is not always null so assert(_hold == null) is not true.
  • error can be avoided if you set _hold=null in _handleDragStart instead 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.

Activity

  1. added
    in triage
    on Oct 4, 2021
  2. maheshj01 commented on Oct 4, 2021

    @maheshj01
    Member

    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.165 channel, when the animation is happening or when it completes if you drag the list the exception is thrown. The issue seems to be with isScrollingNotifier

    wheel.position.isScrollingNotifier.addListener(() {

    reproducible code
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({Key? key, required this.title}) : super(key: key);
    
      final String title;
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      final ScrollController wheel = ScrollController();
      @override
      void initState() {
        WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
          wheel.position.isScrollingNotifier.addListener(() {
            wheel.animateTo(300,
                duration: const Duration(seconds: 10), curve: Curves.linear);
          });
        });
        super.initState();
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: CustomScrollView(slivers: [
            const SliverAppBar(
              expandedHeight: 300,
              title: Text("hello"),
            ),
            SliverFixedExtentList(
              itemExtent: 110,
              delegate: SliverChildBuilderDelegate(
                (context, index) => const Padding(
                  padding: EdgeInsets.only(bottom: 10),
                  child: Card(
                    elevation: 5,
                    child: ListTile(
                      leading: Icon(Icons.icecream),
                      title: Text('I like icecream'),
                      subtitle: Text('Icream is good for health'),
                      trailing: Icon(Icons.food_bank),
                    ),
                  ),
                ),
                childCount: 10,
              ),
            ),
          ], controller: wheel),
        );
      }
    }
    
    flutter doctor -v
    [✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-arm, locale en-GB)
        • Flutter version 2.5.2 at /Users/mahesh/Documents/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 3595343e20 (3 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 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 13.0, Build version 13A233
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.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 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 60.1.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.59.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-arm64   • macOS 11.6 20G165 darwin-arm
        • Chrome (web)    • chrome • web-javascript • Google Chrome 94.0.4606.71
    
    • No issues found!
    
    [✓] Flutter (Channel master, 2.6.0-12.0.pre.165, on macOS 11.6 20G165 darwin-arm, locale en-GB)
        • Flutter version 2.6.0-12.0.pre.165 at /Users/mahesh/Documents/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision a20743ddfe (3 days ago), 2021-09-30 23:43:02 -0400
        • Engine revision 8ec71b64f6
        • Dart version 2.15.0 (build 2.15.0-167.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.0)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.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 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 60.1.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.59.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-arm64   • macOS 11.6 20G165 darwin-arm
        • Chrome (web)    • chrome • web-javascript • Google Chrome 94.0.4606.71
    
    • No issues found!
    
    logs
    Launching lib/main.dart on sdk gphone arm64 in debug mode...
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    ✓  Built build/app/outputs/flutter-apk/app-debug.apk.
    W/FlutterActivityAndFragmentDelegate(13008): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
    Connecting to VM Service at ws://127.0.0.1:50966/MjIAuBu8FFU=/ws
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    The following assertion was thrown while handling a gesture:
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 640 pos 12: '_hold == null': is not true.
    
    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
    #3      DragGestureRecognizer._checkStart.<anonymous closure>
    #4      GestureRecognizer.invokeCallback
    #5      DragGestureRecognizer._checkStart
    #6      DragGestureRecognizer.acceptGesture
    #7      GestureArenaManager._resolveByDefault
    #8      GestureArenaManager._tryToResolveArena.<anonymous closure>
    (elided 12 frames from class _AssertionError and dart:async)
    Handler: "onStart"
    Recognizer: VerticalDragGestureRecognizer#ee77a
        start behavior: start
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 645 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 651 pos 12: '_hold == null || _drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    Application finished.
    Exited (sigterm)
    
    

    @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.

     WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
          wheel.position.addListener(() {
            if (wheel.position.userScrollDirection == ScrollDirection.forward) {
              wheel.animateTo(-1000,
                  duration: const Duration(seconds: 2), curve: Curves.linear);
            } else {
              wheel.animateTo(1000,
                  duration: const Duration(seconds: 2), curve: Curves.linear);
            }
          });
        });
  3. added
    f: scrolling
    found in release: 2.5
    found in release: 2.6
    framework
    has reproducible steps
    and removed
    in triage
    on Oct 4, 2021
  4. Danzo7 commented on Oct 6, 2021

    @Danzo7
    Author

    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.value value is true or false so It look like this:

    void initState() {
        WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
          wheel.position.isScrollingNotifier.addListener(() {
            bool scrollStopped = !wheel.position.isScrollingNotifier.value;
            if (scrollStopped && wheel.position.pixels < 300) {
              if (wheel.position.pixels > 0 && wheel.position.pixels < 300 / 6) {
                wheel.animateTo(0,
                    duration: const Duration(milliseconds: 1000),
                    curve: Curves.easeOutCubic);
              } else if (wheel.position.pixels > (5 * 300) / 6 &&
                  wheel.position.pixels < 300) {
                wheel.animateTo(300,
                    duration: const Duration(milliseconds: 1000),
                    curve: Curves.easeOutCubic);
              } else if (wheel.position.pixels > 300 / 6 &&
                  wheel.position.pixels < (5 * 300) / 6) {
                if (wheel.position.userScrollDirection == ScrollDirection.reverse) {
                  wheel.animateTo(300,
                      duration: const Duration(milliseconds: 1000),
                      curve: Curves.bounceOut);
                } else {
                  wheel.animateTo(0,
                      duration: const Duration(milliseconds: 1000),
                      curve: Curves.bounceOut);
                }
              }
            }
          });
        });
        super.initState();
      }
    

    I did strip all of functionalities in bug_repo before to make it clear for targeting the bug, I updated it again to visualize a real life problem .

    I first use position.addListener() but it was not enough for such a thing as position.isScrollingNotifier.value is always true inside the position.addListener(), I also try to use position.userScrollDirection instead and compare it to ScrollDirection.idle but unfortunately the event stops immediately when u stop scrolling just before position.userScrollDirection is equal to ScrollDirection.idle so it will never be. This is why I use position.isScrollingNotifieraddListener() instead.
    setting _hold=null like 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.dart line:652 :

        // 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);
        if (_hold != null) _hold = null; //add this.
        assert(_drag != null);
        assert(_hold == null);
      }
    

    I'm sure this bug happen because there is an unfinished scroll animation and a user scroll activity at the same time, Making _hold=null will allow to fresh start the user scroll activity(cancel the animation).
    Also according to the scroll_controller.dart line 158-169 animate/jumpTo should be indeed canceled in case of user interruption:

      /// without animation, and without checking if the new value is in range.
      ///
      /// Any active animation is canceled. If the user is currently scrolling, that
      /// action is canceled.
      ///
      /// If this method changes the scroll position, a sequence of start/update/end
      /// scroll notifications will be dispatched. No overscroll notifications can
      /// be generated by this method.
      ///
      /// Immediately after the jump, a ballistic activity is started, in case the
      /// value was out of range.
    
  5. goderbauer commented on Oct 6, 2021

    @goderbauer
    Member

    Duplicate of #14452.

  6. added
    r: duplicate
    on Oct 7, 2021
  7. github-actions commented on Oct 21, 2021

    @github-actions

    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 -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: scrollingfound in release: 2.5found in release: 2.6frameworkhas reproducible stepsr: duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions