2.3 示例
代码
List _list =[1, 2, 3,];
body: RefreshIndicator(
color: Colors.red,
backgroundColor: Colors.lightBlue,
onRefresh: () {
setState(() {
_list.add(_list.length+1);
});
return Future.delayed(Duration(seconds:1));
},
child: ListView.separated(itemCount: _list.length,
separatorBuilder: (context,index){return Divider(height: 10,color: Colors.red,);} ,
itemBuilder: (BuildContext context, int index){
return Center(child: Text(“数据${_list[index]}”),heightFactor: 1.5,);
}, ),
)
效果图
三 CupertinoSliverRefreshControl
3.1 用法说明
-
CupertinoSliverRefreshControl的用法和RefreshIndicator不同,CupertinoSliverRefreshControl需要放在CustomScrollView中
-
CustomScrollView中需要包含两个属性:sliver(滚动试图内容)和physics(滚动对象)
-
sliver:包含CupertinoSliverRefr