防止从外部触摸隐藏showModalBottomSheet

时间:2019-08-22 09:51:31

标签: flutter dart

是否可以防止ModalBottomSheet遮挡外界触摸?像在showDialog()中一样,我们可以使用 barrierDismissible property to prevent dialog from closing on outside touch

4 个答案:

答案 0 :(得分:1)

您需要使用showBottomSheet()(它不包含障碍)来代替showModalBottomSheet()

更多信息here

答案 1 :(得分:0)

Log::info('wtf?!');

enter image description here

答案 2 :(得分:0)

在showModalBottomSheet内部尝试设置isDismissible为false

        showModalBottomSheet(
                    isDismissible: false,
                    context: context,
                    builder: (BuildContext bc) {
                      return SheetWidget();
                    },
                  );

其中SheetWidget是您要称为BottomSheet的小部件

答案 3 :(得分:0)

您可以像这样使用isDismissible: falseenableDrag: false

showModalBottomSheet(
      isDismissible: false,
      enableDrag: false,

      builder: (context) {
        return Container(
         height: 100.0
       )
      }
  );