1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:magpie/magpie.dart' ;
2
3
3
4
void main () => runApp (MyApp ());
4
5
@@ -38,11 +39,63 @@ class MyHomePage extends StatefulWidget {
38
39
39
40
final String title;
40
41
42
+
43
+
41
44
@override
42
45
_MyHomePageState createState () => _MyHomePageState ();
43
46
}
44
47
45
48
class _MyHomePageState extends State <MyHomePage > {
49
+
50
+ @override
51
+ void initState () {
52
+ // TODO: implement initState
53
+ super .initState ();
54
+ Magpie .singleton.registerPageBuilders ({
55
+ 'flutterPage' : (String pageName, Map <String , dynamic > params, String _) {
56
+ print ("flutterPage params:$params " );
57
+ return MyTestRouteWidget ();
58
+ },
59
+ });
60
+ }
61
+
62
+ void _onRoutePushed (
63
+ String pageName,
64
+ String uniqueId,
65
+ Map <String , dynamic > params,
66
+ Route <dynamic > route,
67
+ Future <dynamic > _,
68
+ ) {}
69
+
70
+ @override
71
+ Widget build (BuildContext context) {
72
+
73
+
74
+ return MaterialApp (
75
+ title: 'magpie example' ,
76
+ builder: Magpie .init (postPush: _onRoutePushed),
77
+ home: Container (color: Colors .white));
78
+
79
+ // This method is rerun every time setState is called, for instance as done
80
+ // by the _incrementCounter method above.
81
+ //
82
+ // The Flutter framework has been optimized to make rerunning build methods
83
+ // fast, so that you can just rebuild anything that needs updating rather
84
+ // than having to individually change instances of widgets.
85
+
86
+ }
87
+ }
88
+
89
+
90
+ class MyTestRouteWidget extends StatefulWidget {
91
+
92
+ @override
93
+ State <StatefulWidget > createState () => MyRoute ();
94
+
95
+ }
96
+
97
+ class MyRoute extends State <MyTestRouteWidget > {
98
+
46
99
int _counter = 0 ;
47
100
48
101
void _incrementCounter () {
@@ -58,17 +111,11 @@ class _MyHomePageState extends State<MyHomePage> {
58
111
59
112
@override
60
113
Widget build (BuildContext context) {
61
- // This method is rerun every time setState is called, for instance as done
62
- // by the _incrementCounter method above.
63
- //
64
- // The Flutter framework has been optimized to make rerunning build methods
65
- // fast, so that you can just rebuild anything that needs updating rather
66
- // than having to individually change instances of widgets.
67
114
return Scaffold (
68
115
appBar: AppBar (
69
116
// Here we take the value from the MyHomePage object that was created by
70
117
// the App.build method, and use it to set our appbar title.
71
- title: Text (widget.title ),
118
+ title: Text ("hxin" ),
72
119
),
73
120
body: Center (
74
121
// Center is a layout widget. It takes a single child and positions it
@@ -91,7 +138,7 @@ class _MyHomePageState extends State<MyHomePage> {
91
138
mainAxisAlignment: MainAxisAlignment .center,
92
139
children: < Widget > [
93
140
Text (
94
- 'You have pushed the button this many times:' ,
141
+ 'You have pushed the button this many times now :' ,
95
142
),
96
143
Text (
97
144
'$_counter ' ,
@@ -107,4 +154,6 @@ class _MyHomePageState extends State<MyHomePage> {
107
154
), // This trailing comma makes auto-formatting nicer for build methods.
108
155
);
109
156
}
110
- }
157
+
158
+
159
+ }
0 commit comments