【发布时间】:2020-10-13 06:54:50
【问题描述】:
在这个 sn-p 事件中,值是可以动态变化的流值。
LocationPermissions().serviceStatus.listen((event) {
if(event == ServiceStatus.disabled){
print('Location Disabled');
testAlert(context); // Show dialog
}else{
testAlert(context); //I want hide dialog when user enable location.How do?
print('Location Enabled');
}
}
这是我的对话代码。
void testAlert(BuildContext context){
showDialog(
context: context,
builder: (BuildContext context) {
// return object of type Dialog
return AlertDialog(
title: new Text("Location service disable"),
content: new Text("You must enable your location access"),
actions: <Widget>[
// usually buttons at the bottom of the dialog
new FlatButton(
child: new Text("Go Setting"),
onPressed: () {
openLocationSetting();
//visible ?Navigator.pop(context , true): Navigator.pop(context, false);
},
),
],
);
},
);
}
如何显示和隐藏取决于事件值。谢谢。
【问题讨论】:
-
使用
Navigator.pop(context)隐藏对话框 -
在哪里添加?那个代码兄弟@Jide
-
我写了一个答案。检查一下
标签: android ios flutter mobile widget