refresh method
Future<void>
refresh(
)
override
Implementation
@override
Future<void> refresh() async {
_state.updateState(isRefreshing: true, pageNum: 1);
_state.clearError();
notifyListeners();
try {
final response = await loadData();
_state.clear();
_state.addData(response.data);
_state.updateState(
pageNum: _state.pageNum + 1,
hasMore: _hasMoreData(response),
initialRefresh: false,
isRefreshing: false,
);
refreshController.refreshCompleted();
} catch (e) {
_state.updateState(
hasMore: false,
isRefreshing: false,
error: e.toString(),
);
refreshController.refreshFailed();
} finally {
notifyListeners();
}
}