The short answer to your question is to wrap your bottom sheet with a GestureDetector
and to do some processing in there yourself and avoid the touch event to get to the modal sheet. Here is a link to a similar answer on SO.
From what I understand, ModalBottomSheet
internally uses BottomSheet
and its code, where the actual presentation is done looks like this:
return AnimatedBuilder(
animation: widget.route!.animation!,
child: BottomSheet(
animationController: widget.route!._animationController,
onClosing: () {
if (widget.route!.isCurrent) {
Navigator.pop(context);
}
},
If you look at the onClosing()
callback, it simply dismisses the object without checking with any external callbacks so I don't really think you can achieve that with a modal bottom sheet in Flutter without wrapping it inside a GestureDetector