forked from luhenchang/flutter_study
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReaderme
More file actions
206 lines (178 loc) · 7.16 KB
/
Readerme
File metadata and controls
206 lines (178 loc) · 7.16 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
new Center(
child: new Object_3D(
size: const Size(400.0, 400.0),
path: "assets/NVpose1.obj",
asset:
true), //assets/file.obj为我们的本地obj文件,需要到pubspec.yaml中进行配置
),
showDemoDialog<String>(
context: context,
child: new SimpleDialog(
contentPadding: EdgeInsets.all(0.0),
titlePadding: new EdgeInsets.only(
left: 0.0, bottom: 0.0),
title: new Container(
padding:
new EdgeInsets.all(10.0),
color: Color(0xFF00E5FF),
child: new Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: <Widget>[
Text(
'去购物',
style: TextStyle(
color:
Colors.redAccent),
),
IconButton(
icon: Icon(Icons.clear),
onPressed: () {
Navigator.of(context).pop();
},
color: Colors.white,
),
],
)),
children: <Widget>[
new Container(
height: MediaQuery
.of(context)
.size
.height /
10 *
6,
width: MediaQuery
.of(context)
.size
.width /
10 *
7,
child: Image.asset(
'images/haha.png',
fit: BoxFit.cover,
)),
],
),
);
刷新
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class Example1 extends StatefulWidget {
@override
_Example1State createState() => new _Example1State();
}
class _Example1State extends State<Example1> {
// RefreshMode refreshing = RefreshMode.idle;
// LoadMode loading = LoadMode.idle;
RefreshController _refreshController;
List<Widget> data = [];
void _getDatas() {
for (int i = 0; i < 14; i++) {
data.add(new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data $i'),
),
));
}
}
void enterRefresh() {
_refreshController.requestRefresh(true);
}
void _onOffsetCallback(bool isUp, double offset) {
// if you want change some widgets state ,you should rewrite the callback
}
@override
void initState() {
// TODO: implement initState
_getDatas();
_refreshController = new RefreshController();
super.initState();
}
Widget _headerCreate(BuildContext context, int mode) {
return new ClassicIndicator(
mode: mode,
refreshingText: "",
idleIcon: new Container(),
idleText: "Load more...",
);
}
// Widget _footerCreate(BuildContext context,int mode){
// return new ClassicIndicator(mode: mode);
// }
@override
Widget build(BuildContext context) {
return new Container(
child: new SmartRefresher(
enablePullDown: true,
enablePullUp: true,
controller: _refreshController,
onRefresh: (up) {
if (up)
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
_refreshController.scrollTo(_refreshController.scrollController.offset+100.0);
_refreshController.sendBack(true, RefreshStatus.idle);
setState(() {});
// refresher.sendStatus(RefreshStatus.completed);
});
else {
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
setState(() {});
_refreshController.sendBack(false, RefreshStatus.idle);
});
}
},
onOffsetChange: _onOffsetCallback,
child: new ListView.builder(
reverse: true,
itemExtent: 100.0,
itemCount: data.length,
itemBuilder: (context, index) => new Item(),
)));
}
}
class Item extends StatefulWidget {
@override
_ItemState createState() => new _ItemState();
}
class _ItemState extends State<Item> {
@override
Widget build(BuildContext context) {
return new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data'),
),
);
}
@override
void dispose() {
// TODO: implement dispose
print("销毁");
super.dispose();
}
}
new Stack(
children: <Widget>[new MyContainUtils(""),Card(child:new GestureDetector(),)],
)