// 1、配置路由
import ‘package:flutter/material.dart‘;
import ‘pages/Tabs.dart‘;
import ‘pages/Search.dart‘;
import ‘pages/Form.dart‘;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
// home:Tabs(),
initialRoute: ‘/‘,
routes: {
‘/‘:(contxt)=>Tabs(),
‘/search‘:(contxt) =>SearchPage(),
‘/form‘: (context) => FormPage(),
},
);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 2、路由跳转
RaisedButton(
child: Text("跳转到搜索页面"),
onPressed: (){
Navigator.pushNamed(context, ‘/search‘);
},
color: Theme.of(context).accentColor,
textTheme: ButtonTextTheme.primary
)
————————————————
原文:https://www.cnblogs.com/ly570/p/11402901.html