In this snippet event value is stream value that can change dynamically.
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');
}
}
This is my dialog code.
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);
},
),
],
);
},
);
}
How show and hide depend on event value.Thanks.