import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/http/user.dart'; import 'package:pilipala/models/user/history.dart'; class HistoryController extends GetxController { final ScrollController scrollController = ScrollController(); RxList historyList = [HisListItem()].obs; bool isLoadingMore = false; @override void onInit() { super.onInit(); } Future queryHistoryList({type = 'init'}) async { int max = 0; int viewAt = 0; if (type == 'onload') { max = historyList.last.history!.oid!; viewAt = historyList.last.viewAt!; } isLoadingMore = true; var res = await UserHttp.historyList(max, viewAt); isLoadingMore = false; if (res['status']) { if (type == 'onload') { historyList.addAll(res['data'].list); } else { historyList.value = res['data'].list; } } return res; } Future onLoad() async { queryHistoryList(type: 'onload'); } Future onRefresh() async { queryHistoryList(type: 'onRefresh'); } }