1

I am showing a bottomsheet in flutter by default the isDismissible = false dismissible is set to false but based on certain conditions i want to change this to true i have tried passing a bool to showModalBottomSheet method and changing its value from inside the child widget using setState method but its not working. Any help would be really appreciated.

below is my code for showing bottomsheet

openBottomDialog<T extends StateStreamableSource<Object?>>(
{required BuildContext context,
required Widget child,
double? height,
Function? onClose,
bool? dismissible,
Function? onStateChange}) {
return showModalBottomSheet(
  context: context,
  barrierColor: AppColors.of(context).semiTransparentBackgroundColor,
  backgroundColor: AppColors.of(context).semiTransparentBackgroundColor,
  isScrollControlled: true,
  isDismissible: dismissible ?? false,
  shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.all(Radius.circular(24.r))),
  builder: (model) {
    return BlocProvider.value(
        value: BlocProvider.of<T>(context),
        child: BackdropFilter(
          filter: ImageFilter.blur(sigmaX: 8, sigmaY: 8),
          child: Wrap(
            children: [
              Container(
                decoration: BoxDecoration(
                    color: AppColors.of(context).d15151AwF5F5F5,
                    borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(24.r),
                        topRight: Radius.circular(24.r))),
                // margin: const EdgeInsets.symmetric(horizontal: 10),
                child: Container(
                    margin: const EdgeInsets.all(8),
                    child: Column(
                      children: [
                        AppAsset(
                          key: const Key('close_bottom_sheet'),
                          onTap: () {
                            Navigator.pop(context);
                            onClose!();
                          },
                          asset: AppImages.line,
                          tintColor:
                              AppColors.of(context).bottomSheetHandleColor,
                        ),
                        Container(child: child)
                      ],
                    )),
              )
            ],
          ),
        ));
  });
 }

the child widget is a state full widget and inside that i am using setState method to update this variable.

            setState(() {
              widget.dismissible = false;
              countdownTimer.cancel();
              sliderState = SlideState.loading;
            });
Android
  • 1,085
  • 4
  • 13
  • 28

0 Answers0