reloadData method
Implementation
Future<BaseModel<dynamic>> reloadData({bool isTopLoad = true}) {
refreshApi.isOnLoad = !isTopLoad;
if (isTopLoad) {
refreshApi.page = 1;
} else {
refreshApi.page++;
}
return refreshApi.dispatch().then((value) {
if (isTopLoad) {
list.clear();
}
list.addAll(value.list);
if (refreshApi.isEmptyList != null) {
if (refreshApi.isEmptyList!(value) && !refreshApi.isOnLoad) {
change(list, status: RxStatus.empty());
} else {
change(list, status: RxStatus.success());
}
} else {
if (value.list.isEmpty && !refreshApi.isOnLoad) {
change(list, status: RxStatus.empty());
} else {
change(list, status: RxStatus.success());
}
}
return value;
}, onError: (e) {
change(value, status: RxStatus.error());
refreshApi.page--;
return e;
});
}