【发布时间】:2018-06-21 18:36:13
【问题描述】:
我想使用模态底页进行数据输入。我不希望用户只需触摸工作表外即可将其关闭。本文介绍了如何在 Android 原生中做到这一点。
https://medium.com/@betakuang/make-your-bottomsheetdialog-noncancelable-e50a070cdf07
如何使用颤振小部件做到这一点?
【问题讨论】:
我想使用模态底页进行数据输入。我不希望用户只需触摸工作表外即可将其关闭。本文介绍了如何在 Android 原生中做到这一点。
https://medium.com/@betakuang/make-your-bottomsheetdialog-noncancelable-e50a070cdf07
如何使用颤振小部件做到这一点?
【问题讨论】:
这里
设置 enableDrag false 禁用底部工作表的拖动
设置 isDismissable false 在外部触摸取消时禁用
在 onWillPop 上返回空白会覆盖返回按钮,因此用户无法使用返回按钮返回
showModalBottomSheet(
enableDrag: false,
isDismissible: false,
context: context,
builder: (context) {
return WillPopScope(
onWillPop: () {},
child: Container());
});
【讨论】:
模态BottomSheet的替代是persistent BottomSheet。
您需要做的唯一更改是将showModalBottomSheet 更改为showBottomSheet。
持久 BottomSheet 仍然可以被例如按下返回按钮在 Android 上。这是 nice 行为,因为它是 Material 行为。
【讨论】:
这种做法对我有用!!
showModalBottomSheet(
isDismissible: false, // <--- this line
clipBehavior: ,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25.0), topRight: Radius.circular(25.0)),
),
context: context,
builder: (builder) {
return Container(
child: Column(children: <Widget>[
SizedBox(height: 250,)
]),
);
});
【讨论】: