ReliableCauliflower / flexible_scrollbar

A flexible solution for custom scroll bars
https://pub.dev/packages/flexible_scrollbar/example
Apache License 2.0
6 stars 7 forks source link

Random exception #6

Open lodgmar opened 1 year ago

lodgmar commented 1 year ago

I use FlexibleScrollbar with a CustomScrollView. Of course, they share the same ScrollController.

When I start my application, most of times (but not always) I get this exception several times altogether:

======== Exception caught by gesture ===============================================================
The following _TypeError was thrown while handling a gesture:
Null check operator used on a null value

When the exception was thrown, this was the stack: 
#0      _FlexibleScrollbarState.getBarDelta (package:flexible_scrollbar/src/flexible_scrollbar.dart:502:48)
#1      _FlexibleScrollbarState.changePosition.<anonymous closure> (package:flexible_scrollbar/src/flexible_scrollbar.dart:486:26)
#2      State.setState (package:flutter/src/widgets/framework.dart:1139:30)
#3      _FlexibleScrollbarState.changePosition (package:flexible_scrollbar/src/flexible_scrollbar.dart:485:7)
#4      _FlexibleScrollbarState.build.<anonymous closure>.<anonymous closure> (package:flexible_scrollbar/src/flexible_scrollbar.dart:312:20)
#5      _NotificationElement.onNotification (package:flutter/src/widgets/notification_listener.dart:130:38)
#6      _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3197:18)
#7      _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3200:13)
#8      _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3200:13)
#9      _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3200:13)
#10     _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3200:13)
#11     Element.dispatchNotification (package:flutter/src/widgets/framework.dart:4551:24)
#12     Notification.dispatch (package:flutter/src/widgets/notification_listener.dart:60:13)
#13     DragScrollActivity.dispatchScrollUpdateNotification (package:flutter/src/widgets/scroll_activity.dart:465:139)
#14     ScrollPosition.didUpdateScrollPositionBy (package:flutter/src/widgets/scroll_position.dart:896:15)
#15     ScrollPosition.setPixels (package:flutter/src/widgets/scroll_position.dart:283:9)
#16     ScrollPositionWithSingleContext.setPixels (package:flutter/src/widgets/scroll_position_with_single_context.dart:78:18)
#17     ScrollPositionWithSingleContext.applyUserOffset (package:flutter/src/widgets/scroll_position_with_single_context.dart:122:5)
#18     ScrollDragController.update (package:flutter/src/widgets/scroll_activity.dart:385:14)
#19     ScrollableState._handleDragUpdate (package:flutter/src/widgets/scrollable.dart:745:12)
#20     DragGestureRecognizer._checkUpdate.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:516:55)
#21     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:275:24)
#22     DragGestureRecognizer._checkUpdate (package:flutter/src/gestures/monodrag.dart:516:7)
#23     DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:370:9)
#24     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#25     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#26     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#27     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#28     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#29     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:465:19)
#30     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:445:22)
#31     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:331:11)
#32     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:400:7)
#33     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:363:5)
#34     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:320:7)
#35     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:293:9)
#36     _invoke1 (dart:ui/hooks.dart:158:13)
#37     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:382:7)
#38     _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)
Handler: "onUpdate"
Recognizer: VerticalDragGestureRecognizer#da88d
  start behavior: start

Then , it doesn't show again, and apparently my app is working fine all the time. I mean, those exceptions have no negative effect on user experience, they just appear in my console log.

Basically, my code is like this:

    return Scaffold(
      extendBodyBehindAppBar: true,
      body: FlexibleScrollbar(
        controller: myScreenController.scrollVerticalController,
        jumpOnScrollLineTapped: false,
        child: CustomScrollView(
          controller: myScreenController.scrollVerticalController,
          slivers: [
            // ...
          ],
        ),
      ),
    );
lodgmar commented 1 year ago

Incredible! After 3 or 4 days dealing with this issue, I've found the causing widget. It all happens when I start dragging over a InkWell. Maybe there's no issue with FlexibleScrollbar.

I'll let you know (and probably close issue) as soon as possible.

lodgmar commented 1 year ago

False alarm. InkWell has nothing to do with this issue :-(

So, I leave it open.

More information:

  1. if I drag side to side (obviously scroll view doesn't move) prior to drag down, exceptions don't appear.
  2. if I drag up (scroll view doesn't move either, cause it's at begining), and then I drag down, exceptions don't appear.
  3. Exceptions only appear when I drag down, but scroll view moves correctly. After the few exceptions, they won't appear again, even if I hot-reload my screen. Never appear again until I hot-restart.
  4. No exceptions when I replace FlexibleScrollbar with a standard Scrollbar.