RefreshIndicator

下拉刷新请使用:RefreshIndicator,挺简单,把内容放到child:属性,onRefresh:()async{await}这个无名函数是刷新的具体操作,是一个Future类型的函数。
一个具体的示例:
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('RefreshIndicator'),),
body: RefreshIndicator(
onRefresh: ()async{
await Future.delayed(Duration(seconds: 5));
},
child: ListView(
children: <Widget>[
Image.network('http://www.ecobentech.com/images/1.jpg',fit: BoxFit.cover,),
Image.network('http://www.ecobentech.com/images/2.jpg',fit: BoxFit.cover,),
Image.network('http://www.ecobentech.com/images/3.jpg',fit: BoxFit.cover,),
Image.network('http://www.ecobentech.com/images/4.jpg',fit: BoxFit.cover,),
],
),
),
);
}
}
posted @ 2019-05-14 10:51  braveheart007  阅读(741)  评论(0编辑  收藏  举报