CartListBloc constructor

CartListBloc({
  1. FilterCartModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required CartRepository cartRepository,
  8. 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));
  });
}