buildViewStateEasyRefresh<T> method

Widget buildViewStateEasyRefresh<T>(
  1. {T data,
  2. ScrollController scrollController,
  3. ViewStateModelWidgetListBuilder<T> widgetListBuilder,
  4. ViewStateModelWidgetBuilder<T> widgetBuilder,
  5. Widget busyWidget,
  6. Widget footWidget,
  7. ViewStateWidgetBuilder emptyWidgetBuilder,
  8. ViewStateWidgetBuilder errorWidgetBuilder,
  9. bool showErrorWidget = true,
  10. bool showEmptyWidget = true,
  11. bool showBusyWidget = true,
  12. Function onLoad,
  13. Function onRefresh}
)

------------------------------------------------base下拉刷新控件----------------------------------------------------------

Implementation

Widget buildViewStateEasyRefresh<T>({
    T data,
    ScrollController scrollController,
    ViewStateModelWidgetListBuilder<T> widgetListBuilder,
    ViewStateModelWidgetBuilder<T> widgetBuilder,
    Widget busyWidget,
    Widget footWidget,
    ViewStateWidgetBuilder emptyWidgetBuilder,
    ViewStateWidgetBuilder errorWidgetBuilder,
    bool showErrorWidget = true,
    bool showEmptyWidget = true,
    bool showBusyWidget = true,
    Function onLoad,
    Function onRefresh,
  }){

    List<Widget> widgetList;
    Widget widget;


    if(isNotEmpty(widgetListBuilder)) {
      if(isBusy || isError){
        widgetList = [
          SliverToBoxAdapter(
            child: Container(),
          )
        ];
      }else{
        widgetList = widgetListBuilder(data);
      }
    }else if(isNotEmpty(widgetBuilder)){
      if(isBusy || isError){
        widget = Container();
      }else{
        widget = widgetBuilder(data);
      }
    }


    if(isEmpty(widgetList) && isEmpty(widget)){
      return Container();
    }


    if(isEmpty(footWidget)){
      return buildBaseViewStateEasyRefresh(
          scrollController: scrollController,
          onLoad: onLoad,
          emptyWidgetBuilder: emptyWidgetBuilder,
          errorWidgetBuilder: errorWidgetBuilder,
          onRefresh: onRefresh,
          widget: widget,
          widgetList: widgetList
      );
    }else{
      return Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Expanded(
            child: buildBaseViewStateEasyRefresh(
                scrollController: scrollController,
                onLoad: onLoad,
                emptyWidgetBuilder: emptyWidgetBuilder,
                errorWidgetBuilder: errorWidgetBuilder,
                onRefresh: onRefresh,
                widget: widget,
                widgetList: widgetList
            ),
          ),
          (isNotEmpty(footWidget) && isIdle)? footWidget : Container()
        ],
      );
    }
  }