Flutter &引用;“未找到”;在颤振web上重新加载页面时
在FlatterWeb上,当我在Chrome上重新加载页面时,我会看到文本“未找到”。我怎样才能修好它?这是我的main.dart代码。我还注意到,要直接访问页面,我必须在url中插入一个哈希符号(#),如下所示:“。有没有办法把它去掉Flutter &引用;“未找到”;在颤振web上重新加载页面时,flutter,dart,flutter-web,Flutter,Dart,Flutter Web,在FlatterWeb上,当我在Chrome上重新加载页面时,我会看到文本“未找到”。我怎样才能修好它?这是我的main.dart代码。我还注意到,要直接访问页面,我必须在url中插入一个哈希符号(#),如下所示:“。有没有办法把它去掉 class MyApp extends StatefulWidget { const MyApp({Key key}): super(key: key); @override MyAppState createState() => MyAppState
class MyApp extends StatefulWidget {
const MyApp({Key key}): super(key: key);
@override
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
// This widget is the root of your application.
@override
void initState() {
html.window.history.pushState(null, "Home", "/");
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
initialRoute: "/",
theme: ThemeData(
primarySwatch: Colors.blue,
fontFamily: 'GoogleSansRegular'
),
routes: {
"/": (context) => HomePage(),
"/homepage": (context) => HomePage(),
"/secondPage": (context) => SecondPage()
},
);
}
}
类MyApp扩展StatefulWidget{
constmyapp({Key}):超级(Key:Key);
@凌驾
MyAppState createState()=>MyAppState();
}
类MyAppState扩展了状态{
//此小部件是应用程序的根。
@凌驾
void initState(){
html.window.history.pushState(null,“Home”、“/”;
super.initState();
}
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:“颤振演示”,
初始路径:“/”,
主题:主题数据(
主样本:颜色。蓝色,
fontFamily:“谷歌搜索”
),
路线:{
“/”:(上下文)=>主页(),
“/homepage”:(上下文)=>homepage(),
“/secondPage”:(上下文)=>secondPage()
},
);
}
}