You may see this if you BLoC or Riverpod or just context passing if you try to manage the states of your app.
Actually it’s try to say that, you are using context in your function and you are using in between await keyword.
See the last line, there’s wiggly line. If you hover over your mouse you will see the warning
Do not use BuildContext across async gaps
It’s gives you the warning because, it’s dangerous. Why? Cuz by the time you reach there, the context could be wrong or not there at all.
To get rid of this warning you need to move Nagitor.of(ref.context).pop() at the top. But if we do, we don’t be able to use remove the route or go back to previous page.
Solution
See the first line, we are saving Navigator.of(ref.context) at the top in a variable. You may name the variable anything you want.
And see the last line where we have used context.pop() to get back to previous routes.