路由传值

路由传值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// main.dart
import 'package:demo/pages/Form.dart';
import 'package:demo/pages/Search.dart';
import 'package:flutter/material.dart';
import 'pages/tabs/Tabs.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Tabs(),
routes: {
'/form': (context,{arguments}) => FormPage(arguments: {'id': 'form title'}),
'/search': (context) => SearchPage(),
},
);
}
}


// Form.dart
import 'package:flutter/material.dart';

class FormPage extends StatefulWidget {
final Map arguments;
FormPage({Key key, this.arguments}) : super(key: key);

@override
_FormPageState createState() => _FormPageState();
}

class _FormPageState extends State<FormPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
child: Text('back'),
onPressed: () {
Navigator.of(context).pop();
},
),
appBar: AppBar(
title: Text(widget.arguments['id']),
),
body: Text('表单'),
);
}
}

扫一扫,分享到微信

微信分享二维码
  • Copyrights © 2019-2023 John Doe
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信