7
7
* tartget: page_widgets
8
8
*/
9
9
10
- //import 'package:battery/battery.dart';
11
- import 'dart:io' ;
12
-
13
10
import 'package:d_stack/d_stack.dart' ;
11
+ import 'package:d_stack_example/test_case.dart' ;
14
12
import 'package:flutter/material.dart' ;
15
13
16
14
class Student {
@@ -26,6 +24,29 @@ class Page1 extends StatefulWidget {
26
24
}
27
25
}
28
26
27
+ Widget _caseWidget (List <Map > items) {
28
+ return Center (
29
+ child: ListView .builder (
30
+ itemExtent: 60 ,
31
+ itemCount: items.length,
32
+ itemBuilder: (BuildContext context, index) {
33
+ Map caseMap = items[index];
34
+ return GestureDetector (
35
+ behavior: HitTestBehavior .opaque,
36
+ child: Container (
37
+ alignment: Alignment .center,
38
+ decoration: BoxDecoration (
39
+ border:
40
+ Border (bottom: BorderSide (color: Colors .grey, width: 0.5 ))),
41
+ child: Text (caseMap["text" ]),
42
+ ),
43
+ onTap: caseMap["clicked" ],
44
+ );
45
+ },
46
+ ),
47
+ );
48
+ }
49
+
29
50
class _Page1 extends State <Page1 > {
30
51
@override
31
52
Widget build (BuildContext context) {
@@ -39,57 +60,7 @@ class _Page1 extends State<Page1> {
39
60
},
40
61
)),
41
62
backgroundColor: Colors .white,
42
- body: Center (
43
- child: Column (
44
- children: [
45
- TextField (),
46
- RaisedButton (
47
- child: Text ('push flutter page 2' ),
48
- onPressed: () {
49
- Student student = Student ();
50
- student.name = '😁🍎111' ;
51
- student.age = 12 ;
52
-
53
- // 自定义动画
54
- // DStack.animationPage('page2', PageType.flutter,
55
- // (BuildContext context,
56
- // Animation<double> animation,
57
- // Animation<double> secondaryAnimation,
58
- // WidgetBuilder widgetBuilder) {
59
- // Offset startOffset = const Offset(1.0, 0.0);
60
- // Offset endOffset = const Offset(0.0, 0.0);
61
- // return SlideTransition(
62
- // position: new Tween<Offset>(
63
- // begin: startOffset,
64
- // end: endOffset,
65
- // ).animate(animation),
66
- // child: widgetBuilder(context),
67
- // );
68
- // },
69
- // params: {'key1': 12},
70
- // transitionDuration: Duration(milliseconds: 250));
71
-
72
- // DStack.pushWithAnimation('page2', PageType.flutter,
73
- // (context, animation, secondaryAnimation, child) {
74
- // Offset startOffset = const Offset(1.0, 0.0);
75
- // Offset endOffset = const Offset(0.0, 0.0);
76
- // return SlideTransition(
77
- // position: new Tween<Offset>(
78
- // begin: startOffset,
79
- // end: endOffset,
80
- // ).animate(animation),
81
- // child: child,
82
- // );
83
- // }, popGesture: true);
84
-
85
- DStack .push ('page2' , PageType .flutter).then ((data) {
86
- return print ('pop to Page1 result $data ' );
87
- });
88
- },
89
- ),
90
- ],
91
- ),
92
- ),
63
+ body: _caseWidget (TestCase .openFlutterPageCase),
93
64
);
94
65
}
95
66
@@ -111,41 +82,17 @@ class Page2 extends StatelessWidget {
111
82
leading: RaisedButton (
112
83
child: Text ('返回' ),
113
84
onPressed: () {
114
- Student student = Student ();
115
- student.name = '😁🍎33333' ;
116
- student.age = 12 ;
117
- DStack .pop (result: {'params' : 'value222' }, animated: false );
85
+ DStack .pop ();
118
86
},
119
87
)),
120
- body: Center (
121
- child: RaisedButton (
122
- child: Text ('present flutter page 3' ),
123
- onPressed: () {
124
- // DStack.present('page3', PageType.flutter);
125
- DStack .push ('page3' , PageType .flutter);
126
- },
127
- ),
128
- ),
88
+ body: _caseWidget (TestCase .closeFlutterPage),
129
89
);
130
90
}
131
91
}
132
92
133
93
class Page3 extends StatelessWidget {
134
94
@override
135
95
Widget build (BuildContext context) {
136
- Widget present () {
137
- if (Platform .isIOS) {
138
- return RaisedButton (
139
- child: Text ('Present打开NativePage2' ),
140
- onPressed: () {
141
- DStack .push ("NativePage2" , PageType .native ,
142
- params: {"name" : "flutter 传递的" , "id" : 1000000 });
143
- },
144
- );
145
- }
146
- return Container ();
147
- }
148
-
149
96
return Scaffold (
150
97
appBar: AppBar (
151
98
title: Text ('flutter page3' ),
@@ -155,20 +102,7 @@ class Page3 extends StatelessWidget {
155
102
DStack .pop ();
156
103
},
157
104
)),
158
- body: Center (
159
- child: Column (
160
- children: < Widget > [
161
- RaisedButton (
162
- child: Text ('打开NativePage' ),
163
- onPressed: () {
164
- // DStack.push("NativePage", PageType.native,
165
- // params: {"name": "flutter 传递的", "id": 1000000});
166
- DStack .popTo ("page1" , PageType .flutter, animated: true );
167
- },
168
- ),
169
- present (),
170
- ],
171
- )),
105
+ body: _caseWidget (TestCase .popToPage),
172
106
);
173
107
}
174
108
}
0 commit comments