RefreshIndicator

Posted braveheart007

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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,),
],
),
),
);
}
}

以上是关于RefreshIndicator的主要内容,如果未能解决你的问题,请参考以下文章