Skip to content

Failed assertion in scrollable.dart ('_drag == null': is not true.) #12712

Closed

Description

@amirh

Steps to Reproduce

Just had this happen once when scrolling in the gallery app home screen (Flutter unmodified TOT sycned to cbfed19) with TalkBack on (was scrolling with 2 fingers).
The scroll was not responding and I had this crash in the log.

Couldn't reproduce this again.

Logs

E/flutter ( 3509): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 3509): 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 437: '_drag == null': is not true.
E/flutter ( 3509): #0      _AssertionError._doThrowNew (dart:core-patch/dart:core/errors_patch.dart:37)
E/flutter ( 3509): #1      _AssertionError._throwNew (dart:core-patch/dart:core/errors_patch.dart:33)
E/flutter ( 3509): #2      ScrollableState._handleDragDown (package:flutter/src/widgets/scrollable.dart:437)
E/flutter ( 3509): #3      RawGestureDetectorState._handleSemanticsVerticalDragUpdate (package:flutter/src/widgets/gesture_detector.dart:674)
E/flutter ( 3509): #4      RenderSemanticsGestureHandler._performSemanticScrollUp (package:flutter/src/rendering/proxy_box.dart:3129)
E/flutter ( 3509): #5      SemanticsOwner.performAction (package:flutter/src/rendering/semantics.dart:865)
E/flutter ( 3509): #6      BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding._handleSemanticsAction (package:flutter/src/rendering/binding.dart:188)
E/flutter ( 3509): #7      _invoke2 (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:129)
E/flutter ( 3509): #8      _dispatchSemanticsAction (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:77)

Run flutter analyze and attach any output of that command also.

Analyzing 1277 files...
No analyzer warnings! (ran in 37.8s; 13 public members lack documentation)

Flutter Doctor

$ flutter doctor
[✓] Flutter (on Linux, locale en_US.UTF-8, channel master)
    • Flutter at /usr/local/google/home/amirha/git/flutter
    • Framework revision cbfed1960f (2 hours ago), 2017-10-25 07:18:09 -0700
    • Engine revision ec19da1c80
    • Tools Dart version 1.25.0-dev.11.0

[✓] Android toolchain - develop for Android devices (Android SDK 26.0.2)
    • Android SDK at /usr/local/google/home/amirha/Android/Sdk
    • Platform android-26, build-tools 26.0.2
    • Java binary at: /usr/local/google/home/amirha/progs/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] Android Studio (version 2.3)
    • Android Studio at /opt/android-studio-with-blaze-2.3
    • Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] Android Studio (version 2.3)
    • Android Studio at /usr/local/google/home/amirha/progs/android-studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] IntelliJ IDEA Community Edition (version 2017.2)
    • Flutter plugin version 18.0
    • Dart plugin version 172.4155.35

[✓] Connected devices
    • Pixel • FA6890301419 • android-arm • Android 8.1.0 (API 27)

Activity

  1. added
    customer: galleryRelating to flutter/gallery repository. Please transfer non-framework issues there.
    on Oct 25, 2017
  2. zoechi commented on Dec 3, 2018

    @zoechi
    Contributor

    Looks stale. Is this still relevant?

  3. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Dec 3, 2018
  4. amirh commented on Dec 3, 2018

    @amirh
    ContributorAuthor

    I don't know, it happened once, I guess we can close and re-open if we see it again.

  5. CatEatFishs commented on Jun 17, 2019

    @CatEatFishs

    I have the same problem,how to solve it

    [✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)
    • Flutter version 1.5.4-hotfix.2 at /Users/hongka-liming/Downloads/flutter
    • Framework revision 7a4c334 (7 weeks ago), 2019-04-29 11:05:24 -0700
    • Engine revision 52c7a1e
    • Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)

    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/hongka-liming/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
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:
    brew update
    brew install --HEAD usbmuxd
    brew link usbmuxd
    brew install --HEAD libimobiledevice
    brew install ideviceinstaller
    ✗ ios-deploy not installed. To install:
    brew install ios-deploy
    ✗ Brew can be used to install tools for iOS device development.
    Download brew at https://brew.sh/.

    [✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 35.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

    [✓] Connected device (1 available)
    • COR AL00 • 6EJ7N18526001222 • android-arm64 • Android 9 (API 28)

  6. alexviquez commented on Oct 9, 2019

    @alexviquez

    I got this problem when inactive the scrollPhysics and touch the component who has this scroll inactivated

    StreamBuilder(
                stream: bloc.places,
                initialData: [],
                builder: (context, snapshot) {
                  if (snapshot.data == null) return Container();
                  return StreamBuilder(
                    stream: bloc.scrollable,
                    initialData: true,
                    builder: (context, scroll) =>
                        SingleChildScrollView(
                          controller: listScroll,
                          physics: scroll.data
                              ? NeverScrollableScrollPhysics()
                              : ClampingScrollPhysics(),
                          child: Column(
                            children: snapshot.data
                                .toList()
                                .map<Widget>((place) => _row(context, place, bloc))
                                .toList(),
                          ),
                        ),
                  );
                },
              )
    
  7. TatsuUkraine commented on Oct 21, 2019

    @TatsuUkraine

    @amirh @zoechi still relevant exact same issue with the exact same case as in prev example. It seems that when physics is changing, while scroll was in progress, it doesn't clear prev state of drag and hold

    Code

    StreamBuilder<double>(
              stream: _heightStream,
              initialData: _height.value,
              builder: (context, snapshot) {
                return Container(
                  width: double.infinity,
                  height: snapshot.data,
                  color: Theme.of(context).canvasColor,
                  child: CustomScrollView(
                    controller: _scrollController,
                    physics: _isOpened ? AlwaysScrollableScrollPhysics() : NeverScrollableScrollPhysics(),
                    primary: false,
                    slivers: widget.children,
                  ),
                );
              }
            )

    Exception

    ════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
    The following assertion was thrown while handling a gesture:
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 480 pos 12: '_drag == 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=BUG.md
    
    When the exception was thrown, this was the stack: 
    #2      ScrollableState._handleDragDown (package:flutter/src/widgets/scrollable.dart:480:12)
    #3      DragGestureRecognizer._checkDown.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:359:44)
    #4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
    #5      DragGestureRecognizer._checkDown (package:flutter/src/gestures/monodrag.dart:359:7)
    #6      DragGestureRecognizer.addAllowedPointer (package:flutter/src/gestures/monodrag.dart:236:7)
    ...
    Handler: "onDown"
    Recognizer: VerticalDragGestureRecognizer#d1f23
      start behavior: start
    ════════════════════════════════════════════════════════════════════════════════════════════════════
    
    ════════ (2) Exception caught by gesture ═══════════════════════════════════════════════════════════
    'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 489 pos 12: '_drag == null': is not true.
    ════════════════════════════════════════════════════════════════════════════════════════════════════
    
    
    [✓] Flutter (Channel stable, v1.9.1+hotfix.5, on Mac OS X 10.15 19A602, locale
        ru-UA)
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [✓] Xcode - develop for iOS and macOS (Xcode 11.1)
    [✓] Android Studio (version 3.5)
    [✓] Connected device (1 available)
    
    • No issues found!
    
  8. akshathjain commented on Jan 23, 2020

    @akshathjain

    @amirh Can we reopen this? I've been having the same issue in a very similar scenario to @TatsuUkraine while developing sliding_up_panel.

  9. TatsuUkraine commented on Jan 23, 2020

    @TatsuUkraine

    @akshathjain btw, it seems flutter has built in widget that does exact same as your package

  10. akshathjain commented on Jan 23, 2020

    @akshathjain

    @TatsuUkraine yeah lol, I released my package before that was introduced (although I think that mine provides many more features)

  11. yonatann commented on Apr 15, 2020

    @yonatann

    I am seeing the same issue, I recommend that this will be reopened.

  12. SouravDatta1995 commented on Jun 30, 2020

    @SouravDatta1995

    Seeing the same issue, recommended reopening this issue

  13. 8fdafs2 commented on Jul 1, 2020

    @8fdafs2

    Observing the same issue when attaching a ScrollController to a CustomScrollView widget.

  14. RaashVision commented on Jul 24, 2020

    @RaashVision

    Still having the same issue.

  15. amirc901 commented on Jul 24, 2020

    @amirc901

    Same issue here

    here is a code :

    import 'package:flutter/material.dart';
    import 'package:flutter/rendering.dart';
    
    void main() {
    runApp(MyApplication());
    }
    
    class MyApplication extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: Scaffold(
          body: TestBody(),
        ),
      );
    }
    }
    
    class TestBody extends StatelessWidget {
    
    
    @override
    Widget build(BuildContext context) {
      ScrollController scrollController = ScrollController();
      Size screenSize = MediaQuery.of(context).size;
      return NotificationListener(
        onNotification: (Notification notification) {
          print(notification);
          if (notification is UserScrollNotification) {
    
            if (notification.direction == ScrollDirection.idle) {
              scrollController.animateTo(
                300,
                curve: Curves.ease,
                duration: Duration(milliseconds: 200),
              );
            }
          }
          return false;
        },
        child: ListView.builder(
          controller: scrollController,
          scrollDirection: Axis.vertical,
          itemCount: Colors.primaries.length,
          itemBuilder: (context, index) {
            return Container(
              height: screenSize.width*.3,
              margin: EdgeInsets.all(20),
              color: Colors.primaries[index],
            );
          },
        ),
      );
    }
    }
    
    

    this is happing when you are dragging the list and after you released the drag and list scroll went to an idle state (detecting it in notification listener) than if you could start dragging the list again before the scrollController.animateTo method gets invoked you will see the error is happening

    So i have found a workaround for my case taht is like this :

    
          onNotification: (Notification notification) {
            print(notification);
            if (notification is UserScrollNotification &&
                notification.direction == ScrollDirection.idle) {
              isScrollIdle = true;
              Future.delayed(Duration.zero,() {
                if (isScrollIdle == false) return;
                scrollController.animateTo(
                  300,
                  curve: Curves.ease,
                  duration: Duration(milliseconds: 300),
                );
              });
            }
            return false;
          }
    

    i am postponing the scrollController.animateTo until the next frame and meanwhile, I am listnening to the scroll notifications if there was any notification beside an idle state i would change the isScrollIdle to a false and i am executing the scrollController.animateTo if isScrollIdle is true
    I'm not sure about this workaround and it needs more investigation but for now, it is working for me

  16. Flucadetena commented on Sep 19, 2020

    @Flucadetena

    Still having the same problem! Please reopen this issue.

  17. gadearaujo commented on Sep 27, 2020

    @gadearaujo

    Still having the same problem! Please reopen this issue.

  18. SF-Simon commented on Oct 5, 2020

    @SF-Simon

    Please reopen this issue, Because I have almost the same code as @amirc901 , this problem still exists.

    Flutter 1.22.0 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision d408d30 (6 days ago) • 2020-09-29 11:49:17 -0700
    Engine • revision 5babba6
    Tools • Dart 2.10.0

  19. ivan-pavliuk commented on Oct 14, 2020

    @ivan-pavliuk

    Any updates?

  20. albrownwood commented on Nov 14, 2020

    @albrownwood

    same issue here, any updates?

  21. jja08111 commented on Dec 14, 2020

    @jja08111

    animateTo using ScrollController of NestedScrollView has same issue

  22. mregnauld commented on Jan 10, 2021

    @mregnauld

    Same issue here

  23. Gcii commented on Feb 3, 2021

    @Gcii

    Resolví el problema gracias a TatsuUkraine.
    Efectivamente esto sucede cuando el scroll está en movimiento y se escribe "neverScrollable...".
    Para solucionarlo utilicé timers justo antes de activar "neverScrollable...". y usé otro timer justo después de desactivar.

    I solved the problem thanks to TatsuUkraine.
    Indeed this happens when the scroll is in motion and "neverScrollable ..." is written.
    To fix it I used timers just before activating "neverScrollable ...". and I used another timer right after disabling.

  24. vytautas-pranskunas- commented on Mar 2, 2021

    @vytautas-pranskunas-

    same here

  25. vytautas-pranskunas- commented on Mar 2, 2021

    @vytautas-pranskunas-

    I needed to disable scrolling if calendar was expanded and needed enable scrolling ater calendar is minimized so I have found another workaround:

    basically on swipe up I am moving list by 2 pixels up and adding if check atEgde

    child: Listener(
                        onPointerMove: (PointerMoveEvent details) {
                          if (!_scrollController.position.atEdge &&
                              details.delta.dy < 0 &&
                              _ordersStore.calendarFormat != CalendarFormat.month) {
                            return;
                          }
    
                          if (_ordersStore.calendarFormat == CalendarFormat.month && _isSwipingUp(details)) {
                            _ordersStore.calendarFormat = CalendarFormat.week;
                            // Moving list up in order to be not atEdge otherways double list scroll error kicks in
                            _scrollController.animateTo(
                              2,
                              curve: Curves.ease,
                              duration: Duration(microseconds: 10),
                            );
                          }
    }
    

    also added conditional physics on ListView

    physics: _ordersStore.calendarFormat == CalendarFormat.month
                                    ? NeverScrollableScrollPhysics()
                                    : ClampingScrollPhysics(),
    
  26. github-actions commented on Aug 5, 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.

  27. locked as resolved and limited conversation to collaborators on Aug 5, 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

    customer: galleryRelating to flutter/gallery repository. Please transfer non-framework issues there.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions