dart - 对话框在 Flutter 中关闭
问题描述
通过单击在后台加载哪些数据, 我有一个更新按钮。
当数据加载时,我正在显示AlertDialog,它会在数据加载时自动关闭。
但是,在加载数据时,如果用户单击屏幕上的其他位置,则对话框将关闭,这是不希望的。
问题是如何防止对话框关闭?
Future<void> _loadingDialog(String title) async {
return showDialog(
context: context,
barrierDismissible: true,
builder: (context) {
return AlertDialog(
title: Text(title),
content: LinearProgressIndicator(
backgroundColor: colorPrimaryLight,
valueColor: AlwaysStoppedAnimation<Color>(colorPrimaryDark),
),
);
},
);
}
解决方案
好的,这很简单,我只需要设置
barrierDismissible: false,
推荐阅读
- python - Django - 查询帖子及其回复数?
- web - 我如何在我的网站上显示我的 minecraft 服务器的内存和 cpu 使用情况
- sas - 在 SAS 中从具有递增索引的宏变量创建变量
- javascript - axios拦截器错误处理中的承诺堆栈
- date - 从时间戳到日期的 Cassandra 更改列类型
- wordpress - 如何让我的 URL 和 BreadCrumb 反映我在 WordPress 中的菜单结构?
- python - 带有过滤器的滚动平均值 - Python
- c - .exe 在 C 中无法正确关闭
- javascript - 偶尔 (404) 未找到,用于 SpreadsheetsService.Query
- go - Go API 在 GCP 网络连接中心创建 hub/spoke