modal_bottom_sheet
modal_bottom_sheet copied to clipboard
Drag bug with CustomScrollView and CupertinoSliverRefreshControl
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.
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(
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
@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: [],
);
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.
Confirm downgrading to v2.1.0
solves this issue.