ShopListBloc constructor

ShopListBloc({
  1. FilterShopModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required ShopRepository shopRepository,
  8. int shopLimit = 5,
})

Implementation

ShopListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required ShopRepository shopRepository,
    this.shopLimit = 5})
    : _shopRepository = shopRepository,
      super(ShopListLoading()) {
  on<LoadShopList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadShopListToState();
    } else {
      _mapLoadShopListWithDetailsToState();
    }
  });

  on<NewPage>((event, emit) {
    pages = pages +
        1; // it doesn't matter so much if we increase pages beyond the end
    _mapLoadShopListWithDetailsToState();
  });

  on<ShopChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadShopListToState();
    } else {
      _mapLoadShopListWithDetailsToState();
    }
  });

  on<AddShopList>((event, emit) async {
    await _mapAddShopListToState(event);
  });

  on<UpdateShopList>((event, emit) async {
    await _mapUpdateShopListToState(event);
  });

  on<DeleteShopList>((event, emit) async {
    await _mapDeleteShopListToState(event);
  });

  on<ShopListUpdated>((event, emit) {
    emit(_mapShopListUpdatedToState(event));
  });
}