Reputation: 133
i'm using NetworkGiffyDialog for custom alertdialog But it gives blackscreen background and sometimes apps crash prob here :
onOkButtonPressed: () { Navigator.of(context).pop();
function that i call :
void showAlert(BuildContext context, String txt, String logo) {
showDialog(
context: context,
builder: (_) => NetworkGiffyDialog(
image: Image.asset("Assets/" + logo + ".gif"),
title: Text('Produit Radar',
textAlign: TextAlign.center,
style:
TextStyle(fontSize: 22.0, fontWeight: FontWeight.w600)),
description: Text(
txt,
textAlign: TextAlign.center,
),
onOkButtonPressed: () {
Navigator.of(context).pop();
},
));
}
Upvotes: 1
Views: 2712
Reputation: 1
Set the useRootNavigator attribute of the showAlert class to false.
Upvotes: 0
Reputation: 8714
The context
you are using with this code - Navigator.of(context)
- is the one you are passing to your showAlert
function, which is probably the context of the route on top of which you are displaying the dialog. Because of this, when you call pop()
you are actually popping the route, instead of the dialog. If that is the first route in the navigation stack, the result will be the black screen you mention.
Replace builder: (_)
with builder: (BuildContext context)
so that when you call Navigator.of(context).pop();
you are actually using the dialog's context and as such the dialog will be dismissed.
Upvotes: 2