我已经实现了路由功能,尝试使我的加载页面首先显示,请参见下面的代码。但是,它正在跳过加载页面,直接进入主页,有人可以帮忙吗? (下面的代码)-非常感谢!
import 'package:flutter/material.dart';
import './home.dart';
import './profile.dart';
import 'loading.dart';
import 'search.dart';
void route() => runApp(MaterialApp(
routes: {
'/loading': (context) => LoadingPage(),
'/home': (context) => HomePage(),
'/profile': (context) => ProfilePage(),
},
));
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return MyAppState();
}
}
class MyAppState extends State<MyApp> {
int _selectedPage = 0;
final _pageOptions = [
HomePage(),
SearchPage(),
ProfilePage(),
];
答案 0 :(得分:0)
您可以尝试将此行添加到您的MaterialApp吗?
...
initialRoute:'/ loading'
...