init static method
dynamic
init(
- RefreshController refreshController,
- @required VoidCallback? onRefresh,
- @required VoidCallback? onLoading,
- Widget childWidget, {
- Key? key,
- bool enablePullDown = false,
- bool enablePullUp = false,
- ScrollPhysics physics = const BouncingScrollPhysics(),
- RefreshState loadStatus = RefreshState.INIT,
- Widget? errorWidget,
- Widget? emptyWidget,
- Widget? notNetWidget,
- VoidCallback? onReLoadData,
- VoidCallback? onReFreshFunction,
- bool isCanMoreData = true,
- ScrollController? scrollController,
Implementation
static init(
RefreshController refreshController,@required VoidCallback? onRefresh,@required VoidCallback? onLoading,Widget childWidget,
{
Key? key,
bool enablePullDown:false,
bool enablePullUp:false,
ScrollPhysics physics: const BouncingScrollPhysics(),
RefreshState loadStatus:RefreshState.INIT,
Widget? errorWidget,
Widget? emptyWidget,
Widget? notNetWidget,
VoidCallback? onReLoadData,
VoidCallback? onReFreshFunction,
bool isCanMoreData:true,
double footerHeight:60,
ScrollController? scrollController,
}){
return SmartRefresher(
key: key,
scrollController: scrollController,
controller: refreshController,
enablePullDown: (loadStatus==RefreshState.INIT||loadStatus==RefreshState.OK||loadStatus==RefreshState.EMPTY)?enablePullDown:false,
enablePullUp: (loadStatus==RefreshState.OK&&isCanMoreData==true)?enablePullUp:false,
physics: physics,
child:_setChildUi(loadStatus,childWidget, errorWidget, emptyWidget, notNetWidget,onReFreshFunction),
header: CustomHeader(
builder: (BuildContext context,RefreshStatus? mode){
Widget body ;
if(mode==RefreshStatus.idle){
body = Text("下拉刷新");
}
else if(mode==RefreshStatus.refreshing){
body = CupertinoActivityIndicator();
}
else if(mode == RefreshStatus.failed){
body = Text("刷新再试试");
}
else if(mode == RefreshStatus.canRefresh){
body = Text("释放刷新");
}
else{
body = Text("刷新成功");
}
return Container(
height: 55.0,
child: Center(child:body),
);
},
),
footer: CustomFooter(
builder: (BuildContext context,LoadStatus? mode){
Widget body ;
if(mode==LoadStatus.idle){
body = Text("");
}
else if(mode==LoadStatus.loading){
body = CupertinoActivityIndicator();
}
else if(mode == LoadStatus.failed){
body = Text("加载失败!点击重试!");
}
else if(mode == LoadStatus.canLoading){
body = Text("松手,加载更多!");
}
else{
body = Text("没有更多数据了!");
}
return Container(
height: 30.0,
child: Center(child:body),
);
},
),
onRefresh: onRefresh,
onLoading:onLoading,
);
}