gpt4 book ai didi

flutter - Flutter:如何禁用向下拖动以关闭showModalBottomSheet

转载 作者:行者123 更新时间:2023-12-03 04:54:11 25 4
gpt4 key购买 nike

我想禁用向下拖动以关闭showModalBottomSheet

我已经尝试使用enableDrag:false,
当我使用enableDrag:false,向我显示以下错误时

enter image description here

下面是我的代码

 modal(BuildContext context) {
showModalBottomSheet(
context: context,
enableDrag:false,
isDismissible: false,
backgroundColor: Colors.transparent,
builder: (context) {
return Container(
width: MediaQuery.of(context).size.width,
child: Stack(
alignment: Alignment.topCenter,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.only(top: 30),
child: Stack(
alignment: Alignment.topCenter,
children: <Widget>[
ClipPath(
clipper: OvalTopBorderClipper(),
child: Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.only(top: 80),
color: Colors.white,
height: 440,
child: Text("This is a modal bottom sheet !"),
),
),
],
),
),
Positioned(
top: 5,
child: Container(
width: 50.0,
height: 53.0,
child: Center(
child: Text(
"K",
style: TextStyle(
color: AppColors.textColor, fontSize: 20.0),
),
),
padding:
EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0),
decoration: BoxDecoration(
border:
Border.all(color: AppColors.textColor, width: 2)),
),
),
],
),
);
});
}

我已经检查了这个帖子
  • Disable drag down to close showModalBottomSheet

  • 如果需要更多信息,请告诉我。提前致谢。您的努力将不胜感激。

    最佳答案

    enableDrag中没有showModalBottomSheet。我认为该 channel 无法在稳定 channel 中提供。根据当时链接的评论,该链接可在“主 channel ”中使用。但是该链接的第二个答案很好用

    builder: (context) => GestureDetector(
    onVerticalDragDown: (_) {},
    child: ...,

    hereshowModalBottomSheet的文档。您始终可以点击 showModalBottomSheet并对其进行自定义。

    BottomSheet, which becomes the parent of the widget returned by the function passed as the builder argument to showModalBottomSheet.



    BottomSheet具有 enableDrag参数。

    关于flutter - Flutter:如何禁用向下拖动以关闭showModalBottomSheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60861634/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com