3

just like the title says, when the showModalBottomSheet appear i want to press some button in the body/screen without closing the showModalBottomSheet i already set

isDismissible: false,
barrierColor: Colors.transparent,

but no button can be press

CCP
  • 886
  • 1
  • 10
  • 30

1 Answers1

1

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