2021年4月3日星期六

Navigator 2.0 no initial web page exceptions

I'm using Navigator 2.0 for routing and I build my pages list like this

List<Page<dynamic>> _buildPages() {      List<Page<dynamic>> pages = [];        if (configuration == null) return pages;        if (configuration?.route == Routes.home) {        pages.add(MaterialPage(          key: ValueKey(configuration?.key),          child: HomeScreen(),        ));      }  ...  

This means that the first time the website loads, there will be no initial page, as I don't think that's necessary for a website. It works without side-effects when debugging on Chrome, but I still get an error

The following assertion was thrown: The Navigator.pages must not be empty to use the Navigator.pages API

Is there a way, and is it necessary, to resolve this?

Also I get two other error messages after everything loads.

Another exception was thrown: Navigator.onGenerateRoute was null, but the route named "/" was referenced.

Another exception was thrown: A HeroController can not be shared by multiple Navigators. The Navigators that share the same HeroController are:

I guess the first one points to the fact that I don't have an initial page, but I'm not sure if the second one is related to this?

https://stackoverflow.com/questions/66937189/navigator-2-0-no-initial-web-page-exceptions April 04, 2021 at 09:08AM

没有评论:

发表评论