正如标题说的那样,当showModalBottomSheet出现时,我想按下主体/屏幕上的某个按钮,而不关闭我已经设置的showModalBottomSheet
isDismissible: false,
barrierColor: Colors.transparent,但是没有按钮可以按下
发布于 2022-02-19 13:14:05
对你的问题的简短回答是用一个GestureDetector包你的底部纸,并在里面做一些处理,避免触摸事件到达模态表。Here is a link to a similar answer on SO。
据我所知,ModalBottomSheet内部使用BottomSheet及其代码,实际表示如下所示:
return AnimatedBuilder(
animation: widget.route!.animation!,
child: BottomSheet(
animationController: widget.route!._animationController,
onClosing: () {
if (widget.route!.isCurrent) {
Navigator.pop(context);
}
},如果您查看onClosing()回调,它只是在不检查任何外部回调的情况下关闭对象,因此我认为,如果不将其包装在GestureDetector中,您就不可能完全通过模态底片来实现这一目标。
https://stackoverflow.com/questions/71183999
复制相似问题