0

So I have an showModalBottonSheet, and I want that by default it can close with enableDrag or isDismissible as well, but, when the app is waiting Firebase to respond, after the user search for an object, I want to set enableDrag and isDismissible to false

I already tried setState and even GetX controller as well, I can't set this two to false and change the state after the showModalBottomSheet is constructed, it only works if the modal closes and open again

@override
Widget build(BuildContext context) {
return FloatingActionButton(
  onPressed: () async {
    showModalBottomSheet(
      backgroundColor: Styles.bgColor,
      shape: const RoundedRectangleBorder(
        borderRadius: BorderRadius.vertical(
          top: Radius.circular(25),
        ),
      ),
      isScrollControlled: true,
      context: context,
      builder: (context) {
        return StatefulBuilder(builder: (context, setState) {
          return FractionallySizedBox(
            heightFactor: 0.6,
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Form(
                key: formKey,
                child: modeToAdd
                    ? buildAddManually(setState)
                    : buildAddBySearch(setState),
              ),
            ),
          );
        });
      },
    );
  },
  child: const Icon(Icons.add),
);

}

Mike Jhoe
  • 1
  • 1
  • Please share the code you tried – MrShakila Apr 18 '23 at 03:50
  • Take a look at this similar question: https://stackoverflow.com/questions/52414629/how-to-update-state-of-a-modalbottomsheet-in-flutter – Luke Moody Apr 18 '23 at 06:04
  • @MrShakila added my code. – Mike Jhoe Apr 18 '23 at 12:02
  • @LukeMoody thanks but I already saw and tried this, I can change my state inside the StatefulBuilder, its working OK, but I want to change my state outside the Builder, changing enableDrag and isDismissible of showModalBottomSheet – Mike Jhoe Apr 18 '23 at 12:04

0 Answers0