Flutter Navigator: Dynamic initial route

The documentation for MaterialApp's initialRoute property explains this behavior as follows:

If the route contains slashes, then it is treated as a "deep link", and before this route is pushed, the routes leading to this one are pushed also. For example, if the route was /a/b/c, then the app would start with the three routes /a, /a/b, and /a/b/c loaded, in that order.


"intro": (BuildContext context) => IntroPage()
"home": (BuildContext context) => HomePage()

makes sure that both routes are top-level routes without a parent.


How about just load the desired widget directly as your MaterialApp app home :

return MaterialApp(
      home: isFirstLaunch? IntroScreen():HomeScreen(),
    );