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 {
@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: [
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,),
],
),
),
);
}
}

转载于:https://www.cnblogs.com/braveheart007/p/10861007.html

你可能感兴趣的:(RefreshIndicator)