Search code examples
flutterflutter-showmodalbottomsheet

Flutter: Force modalBottomSheet to only close on button click


I am using a modalBottomSheet to store my user's settings profile. I want to perform a firebase operation on close of the bottom sheet. Is there a way to disable all modalBottomSheet gestures to force the sheet to only close on an icon onTap operation? Thanks


Solution

  • You can set isDismissible and enableDrag to false.

    showModalBottomSheet(
        context: context,
        isDismissible: false,
        enableDrag: false,
        builder: (context) => BottomSheetWidget(),
    );