fujidaiti / smooth_sheets

Sheet widgets with smooth motion and great flexibility.
https://pub.dev/packages/smooth_sheets
MIT License
206 stars 20 forks source link

Lots of assertion errors for unknown reason when using ScrollableSheet but not with DraggableSheet #183

Open mark8044 opened 3 months ago

mark8044 commented 3 months ago

Im getting lots of this with very choppy scroll if I use a ScrollableSheet

======== Exception caught by gesture ===============================================================
The following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/scroll_simulation.dart': Failed assertion: line 39 pos 15: 'leadingExtent <= trailingExtent': 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.yml

When the exception was thrown, this was the stack: 
#2      new BouncingScrollSimulation (package:flutter/src/widgets/scroll_simulation.dart:39:15)
#3      BouncingScrollPhysics.createBallisticSimulation (package:flutter/src/widgets/scroll_physics.dart:732:14)
#4      ScrollPhysics.createBallisticSimulation (package:flutter/src/widgets/scroll_physics.dart:391:20)
#5      ScrollableSheetExtent.goBallisticWithScrollPosition (package:smooth_sheets/src/scrollable/scrollable_sheet_extent.dart:191:10)
#6      DragScrollDrivenSheetActivity.applyUserDragEnd (package:smooth_sheets/src/scrollable/scrollable_sheet_activity.dart:188:11)
#7      SheetDragController.goBallistic (package:smooth_sheets/src/foundation/sheet_drag.dart:321:14)
#8      ScrollDragController.end (package:flutter/src/widgets/scroll_activity.dart:439:14)
#9      SheetDragController.end (package:smooth_sheets/src/foundation/sheet_drag.dart:291:11)
#10     ScrollableState._handleDragEnd (package:flutter/src/widgets/scrollable.dart:854:12)
#11     DragGestureRecognizer._checkEnd.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:832:47)
#12     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:344:24)
#13     DragGestureRecognizer._checkEnd (package:flutter/src/gestures/monodrag.dart:832:5)
#14     DragGestureRecognizer.didStopTrackingLastPointer (package:flutter/src/gestures/monodrag.dart:700:9)
#15     OneSequenceGestureRecognizer.stopTrackingPointer (package:flutter/src/gestures/recognizer.dart:531:9)
#16     DragGestureRecognizer._giveUpPointer (package:flutter/src/gestures/monodrag.dart:709:5)
#17     DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:661:7)
#18     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#19     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#20     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#21     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#22     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#23     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:495:19)
#24     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:475:22)
#25     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:11)
#26     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:420:7)
#27     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:383:5)
#28     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:330:7)
#29     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:299:9)
#30     _invoke1 (dart:ui/hooks.dart:328:13)
#31     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:442:7)
#32     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
(elided 2 frames from class _AssertionError)
Handler: "onEnd"
Recognizer: VerticalDragGestureRecognizer#7825b
  start behavior: start

However if I switch to a DraggableSheet then the errors go away. However, with a DraggableSheet, my column of widgets gets cut and you only can see about half of the column and can never actually scroll to the bottom of the column

Here is my basic code:


GestureDetector(
        onTap: (){
          final modalRoute = ModalSheetRoute(
            barrierColor: Color.fromRGBO(0, 0, 0, 0.8),
            // Enable the swipe-to-dismiss behavior.
            swipeDismissible: true,
            builder: (context) => const ScrollableSheet(
                initialExtent: const Extent. proportional(0.5),
                maxExtent: const Extent. proportional(0.5),
                // physics:
                // BouncingSheetPhysics(
                //   behavior:
                //   DirectionAwareBouncingBehavior(
                //     // Allows the sheet to bounce only when dragging it downwards.
                //     upward: Extent.pixels(0),
                //     downward: Extent.proportional(0.1),
                //   ),
                // ),
                child: CategorySelector()),
          );
CategorySelector widget....

 @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.fromLTRB(24, 20, 24, 20),
        width: double.infinity,
      decoration: BoxDecoration(
        color: Theme.of(context).scaffoldBackgroundColor,
        borderRadius: BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)),
      ),
      child: Material(
        color: Colors.transparent,
        child: SafeArea(
          top:false,
          child: SingleChildScrollView(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("My Categories")
                FutureBuilder(
                  future: getCategories(),
                  builder: (context, snapshot) {

                    if (snapshot.hasData)
                      {

                        return
                        Wrap(
                          children: [

                            for (var thisitem in snapshot.data!)
                             GestureDetector(
                                  onTap: (){
                                    debugPrint(thisitem['categoryid'].toString());
                                  },
                                  child: Container(
                                    margin: const EdgeInsets.fromLTRB(0, 0, 8, 14),
                                    decoration: BoxDecoration(
                                    ),
                                      child: Text(
                                         thisitem['categoryname'].toString(),
                                        style: TextStyle(fontSize: 16),
                                      )
                                  ),
                                )

                          ],
                        );

                      }
                    else
                      {
                           ...
                      }

                  },
                ),
              ],
            ),
          ),
        ),
      )
    );
  }
}
fujidaiti commented 3 months ago

Can you provide some executable code or a screenshot? I couldn't figure out the cause of the problem just from the code provided.

mark8044 commented 3 months ago

Are you on master branch? Also have to scroll up and down in both directions, sometimes it occurs when im scrolling up and reach to the top of my list

fujidaiti commented 3 months ago

Are you on master branch?

Yes, but I need a runnable code to reproduce the problem for further investigation.

mark8044 commented 3 months ago

Are you on master branch?

Yes, but I need a runnable code to reproduce the problem for further investigation.

Oh yes its in the first post at the very bottom. The first paragraph is my tappable widget to open the sheet (named CategorySelector()), then the CategorySelector is in the second paragraph, it is abbreviated but fully runs. If you switch out ScrollableSheet for DraggableSheet in the first paragraph you will see the difference between asserts and no asserts