modal_bottom_sheet icon indicating copy to clipboard operation
modal_bottom_sheet copied to clipboard

Drag bug with CustomScrollView and CupertinoSliverRefreshControl

Open sylvestrevgen opened this issue 2 years ago • 6 comments

When use CustomScrollView, SliverList and CupertinoSliverRefreshControl inside CupertinoScaffold.showCupertinoModalBottomSheet, when drag list down to refresh list with sliver refresh control, modal bottom sheet also is dragging down. How can I fix this problem? I temporarily add enableDrag: false, but it would be great if drag will work correct.

sylvestrevgen avatar Apr 05 '22 13:04 sylvestrevgen

Or if maybe remove drag on list, but keep drag ability to close modal bottom sheet on drag navigation bar inside modal bottom sheet. I use CupertinoPageScaffold inside modal bottom sheet. Maybe I can wrap CupertinoPageScaffold body with specified widget for this, I don't know(

sylvestrevgen avatar Apr 05 '22 13:04 sylvestrevgen

Same with showMaterialModalBottomSheet with SingleChildScrollView inside the body.

Sample code to reproduce the issue:

Widget modalBuilder(BuildContext context) { return FractionallySizedBox( heightFactor: 0.9, child: Container( color: Colors.cyanAccent, padding: const EdgeInsets.only(left: 20, top: 20, right: 20), child: SingleChildScrollView( controller: ModalScrollController.of(context), child: Container( color: Colors.amberAccent, height: 1000, width: double.infinity, child: const SizedBox(), )), ), ); }

class ModalExample extends StatelessWidget { const ModalExample({Key? key}) : super(key: key);

@override Widget build(BuildContext context) { return ElevatedButton( onPressed: () { showMaterialModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: modalBuilder); }, child: const Text('Open modal')); } }

Result: When dragging down by yellow area the area itself moving down faster than the modal:

https://user-images.githubusercontent.com/57828790/174599568-78f44fb9-bfe9-4638-95ec-cfc7cce54946.mov

Expected result: When dragging down by yellow area it is similar with the dragging down by blue area

skorodumoviktor avatar Jun 20 '22 12:06 skorodumoviktor

@sylvestrevgen @skorodumoviktor You need to add physics:ClampingScrollPhysics() to your CustomScrollView.

return CustomScrollView(
        controller: ModalScrollController.of(context),
        /// Creates scroll physics that prevent the scroll offset from exceeding the bounds of the content.
        physics: ClampingScrollPhysics(),     // <- add this here
        slivers: [],
);

ubestudio avatar Jun 28 '22 14:06 ubestudio

I add physics:ClampingScrollPhysics() to GridView but still not work.

Old version seems not have the problem. Hope the showCupertinoModalBottomSheet won't be scroll when we scroll the inner widget. Thanks.

bohowu avatar Sep 19 '22 02:09 bohowu

Confirm downgrading to v2.1.0 solves this issue.

princ3od avatar Sep 10 '23 12:09 princ3od