I am using named routes for navigation in my Flutter Web application. When navigating to the desired route the URL updates but I cannot navigate directly to the route through the URL bar. Every time I try adding a path in the URL it takes me to ".../#/"
When performing a hot reload with an updated URL I get the following error:
Could not navigate to initial route.
The requested route name was: "/Page_One"
There was no corresponding route in the app, and therefore the initial route specified will be ignored and "/" will be used instead.
class Start extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My Site',
theme: ThemeData(...),
initialRoute: '/',
routes: <String, WidgetBuilder> {
"/": (context) => MainPage(),
"/Page_One": (context) => Page2(0),
"/Page_Two": (context) => Page2(1),
"/Page_Three": (context) => Page2(2),
},
);
}
}
EDIT: I have also tried this with onGenerateRoute with no luck.
EDIT2: I am calling these both on a production URL and localhost (ex. http://localhost:12345/#/Page_Two. No, localhost:12345/Page_Two and localhost:12345/#Page_Two do not work either.
Edit3: I am calling runApp by void main() => runApp(new MaterialApp(home: Start()));