小编Jon*_*asH的帖子

以编程方式关闭模态底部图表

我正在showModalBottomSheet<Null>()使用GestureDetector在几个小部件中显示一个BottomSheet .我希望看到BottomSheet不仅通过触摸它而且还在内部的GestureDetector的onTap事件之后关闭.但是,似乎GestureDetector没有转发触摸事件.

所以我想知道,有没有办法以编程方式触发ModalBottomSheet的关闭或告诉GestureDetector转发触摸事件?

更新(2018-04-12):

下面是一个代码片段,以便更好地理解.问题是当点击"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")
      ),
    ]),
  );
});
Run Code Online (Sandbox Code Playgroud)

dart flutter

20
推荐指数
6
解决办法
1万
查看次数

标签 统计

dart ×1

flutter ×1