init static method

dynamic init(
  1. RefreshController refreshController,
  2. @required VoidCallback? onRefresh,
  3. @required VoidCallback? onLoading,
  4. Widget childWidget, {
  5. Key? key,
  6. bool enablePullDown = false,
  7. bool enablePullUp = false,
  8. ScrollPhysics physics = const BouncingScrollPhysics(),
  9. RefreshState loadStatus = RefreshState.INIT,
  10. Widget? errorWidget,
  11. Widget? emptyWidget,
  12. Widget? notNetWidget,
  13. VoidCallback? onReLoadData,
  14. VoidCallback? onReFreshFunction,
  15. bool isCanMoreData = true,
  16. double footerHeight = 60,
  17. 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,
  );
}