update pagination listener
This commit is contained in:
@@ -81,7 +81,7 @@ class CartonModel extends BaseModel {
|
||||
|
||||
set selectedIndexFilter(int index) {
|
||||
_selectedIndexFilter = index;
|
||||
_loadCartonsByFilter(
|
||||
_loadPaginationCartons(
|
||||
_selectedIndexFilter == 1 ? "carton_weight" : "user_name");
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -109,12 +109,8 @@ class CartonModel extends BaseModel {
|
||||
Future<void> _initData() async {
|
||||
logout();
|
||||
_selectedIndexFilter = 1;
|
||||
cartonsByFilter = PaginatorListener<Carton>(
|
||||
(data, id) => Carton.fromMap(data, id), onChange: () {
|
||||
notifyListeners();
|
||||
}, rowPerLoad: 30, insertNewByListener: true);
|
||||
|
||||
_loadCartonsByFilter(
|
||||
_loadPaginationCartons(
|
||||
_selectedIndexFilter == 1 ? "carton_weight" : "user_name");
|
||||
}
|
||||
|
||||
@@ -146,30 +142,26 @@ class CartonModel extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadCartonsByFilter(String orderName) async {
|
||||
_loadPaginationCartons(String orderName) {
|
||||
if (user == null || !user!.hasCarton()) return null;
|
||||
String path = "/$cartons_collection";
|
||||
|
||||
try {
|
||||
Query listenerQuery = FirebaseFirestore.instance
|
||||
.collection("$path")
|
||||
.where("carton_type", whereIn: [
|
||||
carton_from_packages,
|
||||
carton_from_cartons
|
||||
]).where("status", isEqualTo: carton_packed_status);
|
||||
Query col = FirebaseFirestore.instance.collection(path).where("carton_type",
|
||||
whereIn: [
|
||||
carton_from_packages,
|
||||
carton_from_cartons
|
||||
]).where("status", isEqualTo: carton_packed_status);
|
||||
Query pageQuery = FirebaseFirestore.instance
|
||||
.collection(path)
|
||||
.where("carton_type",
|
||||
whereIn: [carton_from_packages, carton_from_cartons])
|
||||
.where("status", isEqualTo: carton_packed_status)
|
||||
.orderBy(orderName, descending: true);
|
||||
|
||||
Query pageQuery = FirebaseFirestore.instance
|
||||
.collection("$path")
|
||||
.where("carton_type",
|
||||
whereIn: [carton_from_packages, carton_from_cartons])
|
||||
.where("status", isEqualTo: carton_packed_status)
|
||||
.orderBy(orderName, descending: true);
|
||||
|
||||
cartonsByFilter!
|
||||
.refresh(listeningQuery: listenerQuery, pageQuery: pageQuery);
|
||||
} catch (e) {
|
||||
log.warning("Error!! $e");
|
||||
}
|
||||
cartonsByFilter?.close();
|
||||
cartonsByFilter = PaginatorListener<Carton>(
|
||||
col, pageQuery, (data, id) => Carton.fromMap(data, id),
|
||||
rowPerLoad: 30);
|
||||
}
|
||||
|
||||
Paginator? _getDelivered() {
|
||||
|
||||
Reference in New Issue
Block a user