import 'dart:collection'; import 'package:get/get.dart'; import 'package:vnoteapp/architecture/defines.dart'; /// 分页状态Mixin mixin PagedStateMixin { final RxString _searchString = RxString(""); final RxInt _pageIndex = RxInt(0); final RxInt _pageSize = RxInt(20); final RxInt _totalCount = RxInt(0); final RxList _dataList = RxList(); /// 模糊搜索字符串 String get searchString => _searchString.value; set searchString(String val) => _searchString.updateValue(val); /// 当前页索引 int get pageIndex => _pageIndex.value; set pageIndex(int val) => _pageIndex.updateValue(val); /// 每页数量 int get pageSize => _pageSize.value; set pageSize(int val) => _pageSize.updateValue(val); /// 总数据量 int get totalCount => _totalCount.value; set totalCount(int val) => _totalCount.updateValue(val); /// 是否存在下一页 bool get hasNextPage => _totalCount > pageIndex * pageSize; /// 列表数据集合 List get dataList => UnmodifiableListView(_dataList.toList()); set dataList(List val) => _dataList.value = val; /// 追加数据集合 void appendDataList(List arr) { List newArray = List.from(_dataList); newArray.addAll(arr); _dataList.value = newArray; } }