【发布时间】:2020-12-29 15:04:38
【问题描述】:
我使用flutter已经有一段时间了,最近使用Get来实现状态管理。 第一次打开加载对话框然后打开消息对话框时遇到问题。然后我想关闭加载对话框,但消息对话框是一直关闭的。
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class HomeController extends GetxController {
Future<void> openAndCloseLoadingDialog() async {
showDialog(
context: Get.overlayContext,
barrierDismissible: false,
builder: (_) => WillPopScope(
onWillPop: () async => false,
child: Center(
child: SizedBox(
width: 60,
height: 60,
child: CircularProgressIndicator(
strokeWidth: 10,
),
),
),
),
);
await Future.delayed(Duration(seconds: 3));
Get.dialog(
AlertDialog(
title: Text("This should not be closed automatically"),
content: Text("This should not be closed automatically"),
actions: <Widget>[
FlatButton(
child: Text("CLOSE"),
onPressed: () {
Get.back();
},
)
],
),
barrierDismissible: false,
);
await Future.delayed(Duration(seconds: 3));
Navigator.of(Get.overlayContext).pop();
}
}
上面的代码关闭了第二个对话框,而不是我想要的第一个对话框。 任何人都可以就这个问题提供建议。
【问题讨论】:
标签: flutter flutter-getx