问题描述
我想禁用向下拖动以关闭showModalBottomSheet
I want to disable drag down to close the showModalBottomSheet
我已经尝试使用 enableDrag:false,
当我使用 enableDrag:false时,
向我显示错误
下面是我的代码
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)),
),
),
],
),
);
});
}
我已经检查过此帖子
如果需要更多信息,请告诉我.提前致谢.您的努力将不胜感激.
If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.
推荐答案
enableDrag
在 showModalBottomSheet
中不可用.我认为该频道无法在稳定频道中提供.根据当时链接的评论,该链接可在主频道"中使用.但是该链接的第二个答案效果很好
enableDrag
is not available in showModalBottomSheet
. I don't think it was ever available in stable channel. According to comments from the link at that time it was available in Master channel. But second answer from that link works well
builder: (context) => GestureDetector(
onVerticalDragDown: (_) {},
child: ...,
此处是 showModalBottomSheet
的文档.您始终可以点击 showModalBottomSheet
并对其进行自定义..根据doc
here is documentation to showModalBottomSheet
. You can always tap into the showModalBottomSheet
and customise it.. According to doc
和 BottomSheet 具有 enableDrag
范围.
这篇关于Flutter:如何禁用向下拖动以关闭showModalBottomSheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!