-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#17580Labels
f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.platform-webWeb applications specificallyWeb applications specifically
Description
Steps to Reproduce
- Add two named routes to app using "routes" property of MaterialApp class.
- Add two button to each widget.on click of button navigate between screens
- Navigation works with button click but if you hit url directly in browser or refresh the page then app crashed.It will not work with bookmarked pages.
**Exception**
The following message was thrown:
Could not navigate to initial route.
The requested route name was: "/product"
There was no corresponding route in the app, and therefore the initial route specified will be
ignored and "/" will be used instead.
** Code **
// my app widget
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo!!!',
home: Home(),
routes: {'home': (_) => Home(), 'product': (_) => Product()},
);
}
}
// product widget
class Product extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Column(
children: <Widget>[
Text('Product'),
FlatButton(
onPressed: () {
Navigator.pushNamed(
context,
'home',
);
},
child: Text('click'))
],
),
);
}
}
// home widget
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Column(
children: <Widget>[
Text('Home'),
FlatButton(
onPressed: () {
Navigator.pushNamed(
context,
'product',
);
},
child: Text('click'))
],
),
);
}
}
VladyslavBondarenko and zs-dima
Metadata
Metadata
Assignees
Labels
f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.platform-webWeb applications specificallyWeb applications specifically