考虑我的情景
//Show the progress indicator inside an alert to block the user
showAlertProgressIndicator();
// Get the data
await DataManager.get().getDummyData().then((value){
// After data acquisition pop the alertProgressIndicator
});
我怎样才能做到这一点?
我认为它应该是简单的Navigator.pop(context);
或
void closeAlert() {
Navigator.pop(context);//it will close last route in your navigator
}
我猜这两种方法在同一个build()
。所以他们有相同的BuildContext
,所以上面应该工作。
我创建了一个与这种情况相关的示例应用程序。它在这里https://github.com/Yahhi/flutter_dialog_test上下文相同,并且在定时器事件5秒后对话框消失。
Navigator.of(context).pop();