Walter M
Walter M

Reputation: 5543

Can someone explain "Navigator.of" in Flutter?

I am having trouble understanding what Navigator.of is and what it is used for. I have already read the documentation but the explanation is vague.

https://docs.flutter.io/flutter/widgets/Navigator/of.html

Upvotes: 1

Views: 1414

Answers (1)

Shaode Lu
Shaode Lu

Reputation: 251

In general, one Flutter project has one MaterialApp, one MaterialApp has one Navigator, and many Scaffold. Scaffold means page in flutter. so Navigator control the route between Scaffolds in one MaterialApp.

So Navigator.of(context) means find the (state of) Navigator in the MaterialApp by the context of Scaffold.

Upvotes: 1

Related Questions