【发布时间】:2018-09-21 13:30:24
【问题描述】:
我正在通过showModalBottomSheet<Null>() 和几个带有 GestureDetector 的小部件显示一个 BottomSheet。
我希望看到 BottomSheet 不仅通过触摸它的外部而且在内部的 GestureDetector 的 onTap 事件之后关闭。但是,GestureDetector 似乎没有转发触摸事件。
所以我想知道,有没有办法以编程方式触发 ModalBottomSheet 的关闭,或者告诉 GestureDetector 转发触摸事件?
更新(2018-04-12):
以下代码 sn-p 以便更好地理解。问题是当点击“Item 1”或“Item 2”时,ModalBottomSheet 没有关闭。
showModalBottomSheet<Null>(context: context, builder: (BuildContext context)
{
return new SingleChildScrollView(child:
new Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
new GestureDetector(onTap: () { doSomething(); }, child:
new Text("Item 1")
),
new GestureDetector(onTap: () { doSomething(); }, child:
new Text("Item 2")
),
]),
);
});
【问题讨论】:
-
“内外”这太不清楚了,您可能需要包含插图或显示相关代码