CartListBloc constructor
CartListBloc({
- FilterCartModels? filter,
- bool? paged,
- String? orderBy,
- bool? descending,
- bool? detailed,
- EliudQuery? eliudQuery,
- required CartRepository cartRepository,
- int cartLimit = 5,
Implementation
CartListBloc(
{this.filter,
this.paged,
this.orderBy,
this.descending,
this.detailed,
this.eliudQuery,
required CartRepository cartRepository,
this.cartLimit = 5})
: _cartRepository = cartRepository,
super(CartListLoading()) {
on<LoadCartList>((event, emit) {
if ((detailed == null) || (!detailed!)) {
_mapLoadCartListToState();
} else {
_mapLoadCartListWithDetailsToState();
}
});
on<NewPage>((event, emit) {
pages = pages +
1; // it doesn't matter so much if we increase pages beyond the end
_mapLoadCartListWithDetailsToState();
});
on<CartChangeQuery>((event, emit) {
eliudQuery = event.newQuery;
if ((detailed == null) || (!detailed!)) {
_mapLoadCartListToState();
} else {
_mapLoadCartListWithDetailsToState();
}
});
on<AddCartList>((event, emit) async {
await _mapAddCartListToState(event);
});
on<UpdateCartList>((event, emit) async {
await _mapUpdateCartListToState(event);
});
on<DeleteCartList>((event, emit) async {
await _mapDeleteCartListToState(event);
});
on<CartListUpdated>((event, emit) {
emit(_mapCartListUpdatedToState(event));
});
}