1

I would like to change the state my showModalBottomSheet is in. Specifically change enableDrag and isDismissible between true/false without showing a new modal or replacing the one that is already rendered. Is this currently possible at all?

bool allowDismiss = false; // change this variable after render

showModalBottomSheet(
          context: context,
          isScrollControlled: true,
          isDismissible: allowDismiss, 
          enableDrag: allowDismiss,
          shape: RoundedRectangleBorder(
            borderRadius:
                BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30)),
          ),
          builder: (context) => Container(height: 400),
        )
Isak dl
  • 448
  • 3
  • 13
  • 1
    you want to change the behaviour based on what condition? – HII May 14 '20 at 14:37
  • Some state of the child view, ie I want to disable the dismiss behavior while I'm displaying a loading state, but allow it while in any other state. – Isak dl May 14 '20 at 15:44
  • check this https://github.com/flutter/flutter/pull/46685#issuecomment-598236647 – HII May 14 '20 at 16:50
  • Isn't that just the enableDrag property got implemented for showModalBottomSheet? What I want to do is change that variable AFTER the modal has been rendered. – Isak dl May 14 '20 at 19:02
  • You can set that property to follow a boolean that you save as a field in your class, and change it on some condition using `setState` – HII May 14 '20 at 19:23
  • But that will that not just push a new modal to the navigation stack? Rather than rerender the modal. – Isak dl May 14 '20 at 19:26

0 Answers0