//使用时 无法触发 两个监听 同样没显示 小圈圈 是我使用的有问题吗?
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
),
home: new HomeScreen(),
debugShowCheckedModeBanner: false,
);
}
}
class HomeScreen extends StatefulWidget {
@OverRide
_HomeScreenState createState() => new _HomeScreenState();
}
class _HomeScreenState extends State {
List _notices =
[Notice("呵呵","哈哈"),
Notice("呵呵","哈哈")
,Notice("呵呵","哈哈"),
Notice("呵呵","哈哈"),
Notice("呵呵","哈哈")
,Notice("呵呵","哈哈"),
Notice("呵呵","哈哈"),
Notice("呵呵","哈哈")];
@OverRide
build(BuildContext context) {
return new Material(
child: new SwipeRefreshLayout(
onLoad: onRefresh,//Futrue
onLoadMore: onLoadMore,//Futrue
child: new ListView(
children: _notices.map((Notice notice) {
return new ListTile(
title: new Text(notice.title),
subtitle: new Text(notice.content));
}).toList(),
)),
);
}
}
class Notice{
String title;
String content;
Notice(this.title,this.content);
}
Future onRefresh() {
print("触发refresh");
final Completer completer = new Completer();
new Timer(const Duration(microseconds: 5), () {
completer.complete(null);
});
return completer.future.then((_) {
print("refresh完成");
});
}
Future onLoadMore() {
print("触发onLoadMore");
final Completer completer = new Completer();
new Timer(const Duration(microseconds: 5), () {
completer.complete(null);
});
return completer.future.then((_) {
print("onLoadMore完成");
});
}