Named routes

// 1, configure routing
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 is
13 is
14
15
16
. 17
18 is
. 19
20 is
21 is
22 is
23 is
24
// 2, Route jump
RaisedButton (
Child: the Text ( "search jump to the page"),
onPressed: () {
Navigator.pushNamed (context, '/ Search');
},
Color: Theme.of (context) .accentColor,
textTheme: ButtonTextTheme.primary
)
----------------

Guess you like

Origin www.cnblogs.com/ly570/p/11402901.html