Member-only story
FLUTTER INTERVIEW QUESTIONS
Who creates a Navigator in Flutter?
…and where can you can find it?
2 min readApr 2, 2020
For many Flutter developers(both new ones and those a bit more experienced), Navigator is something they use on a daily basis, but they have never created an instance of it, or even know where it comes from.
Weird, isn’t it?
What is the Navigator anyway? A Widget?
Yes, it’s a Widget and it’s used for displaying screens(Routes in Flutter) on the top of each other(like in Stack). Most of the times we use .push() and .pop() methods, for displaying and removing screens, respectively.
If we try to use it like this:
We will get an Exception that says:
The following assertion was thrown while handling a gesture:
Navigator operation requested with a context that does not include a Navigator.The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.
But, if we add a MaterialApp widget as Builder’s parent, it will work.
Why?