0

I have a global stream and it's listener. Simply, if something was added to the stream, the app will call showModalBottomSheet function. The problem is, sometimes in the process I have to add two value to the stream, but I only want one modal bottom sheet to be shown.

I was looking for how to close current shown bottom sheet in Flutter as we do with the Snackbar by invoking ScaffoldMessenger.of(context).hideCurrentSnackbar().

I've looked here on how to close a bottom sheet programmatically using PersistentBottomSheetController but I think it doesn't suit in my problem since I use the showModalBottomSheet which is not a part of Scaffold.

Is there any way I can achieve this?

Naufal Rajabi
  • 334
  • 4
  • 13
  • Have you tried using a boolean flag to check whether a Bottom Sheet is already opened before invoking showModalBottomSheet? – Lee Boon Kong Mar 29 '23 at 05:09
  • Thanks for the reply. It can be an alternative, but I think there is another way to do it other than having a global boolean flag since this modal bottom sheet need to be controlled globally. – Naufal Rajabi Mar 29 '23 at 14:33

0 Answers0