【发布时间】:2022-01-22 13:51:54
【问题描述】:
我正在使用 GetX。我正在显示两个对话框。一个在底部,一个在顶部。当我单击顶部对话框上的按钮时,我想关闭底部对话框,怎么办?请看下面的代码:
Get.dialog(
Container(
width: double.infinity,
height: double.infinity,
alignment: Alignment.center,
child: Text("Bottom Dialog")),
name: "dialog1");
Future.delayed(Duration(seconds: 1), () {
Get.dialog(
Container(
width: double.infinity,
height: double.infinity,
alignment: Alignment.topRight,
child: GestureDetector(
onTap: () {
print("close");
Get.removeRoute(GetPageRoute(routeName: "dialog1"));
// Get.key.currentState!.removeRoute(GetPageRoute(routeName: "dialog1"));
},
child: Text("Top Dialog"))),
navigatorKey: Get.key);
});
【问题讨论】:
-
尽管使用 getx Get.back() 有时会给我带来问题,因此我最终使用了
Navigator.pop(context)
标签: flutter flutter-getx