ShopFrontListBloc constructor

ShopFrontListBloc({
  1. FilterShopFrontModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required ShopFrontRepository shopFrontRepository,
  8. int shopFrontLimit = 5,
})

Implementation

ShopFrontListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required ShopFrontRepository shopFrontRepository,
    this.shopFrontLimit = 5})
    : _shopFrontRepository = shopFrontRepository,
      super(ShopFrontListLoading()) {
  on<LoadShopFrontList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadShopFrontListToState();
    } else {
      _mapLoadShopFrontListWithDetailsToState();
    }
  });

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

  on<ShopFrontChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadShopFrontListToState();
    } else {
      _mapLoadShopFrontListWithDetailsToState();
    }
  });

  on<AddShopFrontList>((event, emit) async {
    await _mapAddShopFrontListToState(event);
  });

  on<UpdateShopFrontList>((event, emit) async {
    await _mapUpdateShopFrontListToState(event);
  });

  on<DeleteShopFrontList>((event, emit) async {
    await _mapDeleteShopFrontListToState(event);
  });

  on<ShopFrontListUpdated>((event, emit) {
    emit(_mapShopFrontListUpdatedToState(event));
  });
}