Closed AkbarBakhshi closed 3 years ago
I tried running your code but seems like you are using your own widgets. But what I think the problem here is that context
is not correct. When we use the rootNavigator
property in showModalBootomSheet
, it creates a new context
out of scope of the previous one so we don't see the navigation bar. But if we don't use that property, we see the navigation bar because we are using the context
of the selected screen of the navigation bar which is lower in the hierarchy compared to the navigation bar.
I just replaced the onPressed
function of one of the buttons in your example with the code above and then the Navigator.pop(context)
from the code above popped the tab screen instead of alert. I do agree with you that the problem is most probably the context
. Can you think of a workaround or something for these two packages to work together?
I guess you will have to modify this package. I did find the field useRootNavigator
in its code but it is a constant value set to true.
/// Displays defined alert window
Future<bool> show() async {
return await showGeneralDialog(
context: context,
pageBuilder: (BuildContext buildContext, Animation<double> animation,
Animation<double> secondaryAnimation) {
return _buildDialog();
},
barrierDismissible: style.isOverlayTapDismiss,
barrierLabel:
MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: style.overlayColor,
useRootNavigator: true,
transitionDuration: style.animationDuration,
transitionBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) =>
alertAnimation == null
? _showAnimation(animation, secondaryAnimation, child)
: alertAnimation(
context, animation, secondaryAnimation, child));
}
Another workaround that could possibly work (haven't tested it) is to pass the context from the first screen in the app and use that instead.
Another workaround that could possibly work (haven't tested it) is to pass the context from the first screen in the app and use that instead.
Yep.. When I pass menuScreenContext as the context of the Alert and then I pop the Alert using Navigator.of(menuScreenContext).pop()
, it works. Thanks for the help!
Hi, Thank you very much for this great package. I am using rflutter_alert from here with your package. However, for example let's say in your example code, if I replace a showmodalBootomSheet with the code below to show an alert, once I click on the dialog button to pop the alert, it pops the main screen instead. Am I doing something wrong? Or is this an issue with your package or the other package? Thank you!