如何在颤动中单击(关闭)按钮时关闭抽屉?

问题描述 投票:0回答:1

如果单击在抽屉右上角创建的关闭按钮,是否有关闭抽屉的方法。

抽屉模拟:

drawer mock

flutter flutter-layout
1个回答
0
投票

只需调用Navigator.of(context).pop();

示例:

ListTile(
  title: Text('Item 1'),
  onTap: () {
    // Update the state of the app.
    // ...
    // Then close the drawer.
    Navigator.pop(context);
  },
),

参考

© www.soinside.com 2019 - 2024. All rights reserved.