loadMore method

Future<List<T>> loadMore()

上拉加载更多

Implementation

Future<List<T>> loadMore() async {
  try {
    final data = (await getList(pageNum: ++_currentPageNum)) ?? [];
    if (data.isEmpty) {
      _currentPageNum--;
      refreshController.loadNoData();
    } else {
      _list.addAll(data);
      if (data.length < _pageSize) {
        refreshController.loadNoData();
      } else {
        refreshController.loadComplete();
      }

      /// 获取数据后
      afterGetList(data, currentPageNum);
    }
    return data;
  } catch (e, s) {
    _currentPageNum--;
    refreshController.loadFailed();
    XLog.e('error--->\n' + e.toString());
    XLog.e('statck--->\n' + s.toString());
    return [];
  }
}