Why: How does app start the first route to the flutter end?

Related classes: materialApp, widgetsApp, Navigator class.

In general: we return the materialApp directly in the main() method. We will fill the initialRoute, home, onGenearatorRoute, onUnkownRoute these attribute values.

The first step is the materialApp Buid () method

The second step, widgetsApp’s Build method, creates the Navigator object

The red box above indicates whether the initialRoute value was modified or not

Third, how does navigator push the first route and analyze its initState method



The two _routeNamed() in the red box are used to generate the Route object

Step 4: How to generate a route object

One of the widget.onGenerateroute () calls the _onGenerateRoute() method in widgets



The red box inside will eventually call the onGenerateor function of the property we configured for materialApp to generate the route.

The first _routeNamed() method finds the route corresponding to the initialRoute. If it does not find the route, the second _routeNamed() method uses the default ‘/’ route to find the route to the home attribute.

Remember: routing for the steps of: initialRoute, home, onGenerateRoute, onUnkownRoute