防止隐藏 showModalBottomSheet 免受外部触摸

Gov*_*iyo 6 dart flutter

是否可以防止ModalBottomSheet隐藏免受外界接触?就像showDialog()我们可以使用属性来防止对话框在外部触摸时关闭barrierDismissible

小智 6

你可以使用isDismissible: falseenableDrag: false喜欢这个

showModalBottomSheet(
      isDismissible: false,
      enableDrag: false,

      builder: (context) {
        return Container(
         height: 100.0
       )
      }
  );
Run Code Online (Sandbox Code Playgroud)


Cop*_*oad 3

您需要使用showBottomSheet()which 不包含barrier 而不是使用showModalBottomSheet().

更多信息请点击此处

  • “showModalBottomSheet”和“showBottomSheet”之间的唯一区别是后者不能通过触摸其上下文之外来关闭。这不正是你所要求的吗? (2认同)