(Possible Bug) Pop dialog doesn't work in Flutter Test ? #2188
Unanswered
tperin-cap
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
TL;DR
Hello all! I'm writing tests for a service that shows pop-up in my app and when I'm trying to close the pop-up dialog with Autorouter.pop, it's not working, whereas Navigator.of(context).pop works just fine.
Context
My autorouter class is registered in a GetIt instance and called AppRouter. So when I want to navigate, all I go is "getIt().push(...)" or ".pop(...)". It works just fine.
My pop-up service looks like this
Issue
When I want to show a dialog, I'll call
getIt<PopUpService>().showPopUp()which turnsisPopUpVisibletotrue, then the user clicks the button which callslocator<AppRouter>().pop()and closes the dialog.This works just fine in the app.
Now I'm running this test:
Pump a Widget with a button to call show dialog --> pump --> press the button --> pump --> verify the Dialog widget is found --> press close --> pump --> verify the Dialog widget is gone
If I have
onPressed: () => Navigator.of(context).pop(), this works.If I have it as it is in the code snippet above, this doesn't work.
Am I missing something or is it a bug ?
Beta Was this translation helpful? Give feedback.
All reactions