通过单击后台加载的数据,我有一个更新按钮。
当数据加载时,我显示的是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,