AlbumListBloc constructor

AlbumListBloc({
  1. FilterAlbumModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required AlbumRepository albumRepository,
  8. int albumLimit = 5,
})

Implementation

AlbumListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required AlbumRepository albumRepository,
    this.albumLimit = 5})
    : _albumRepository = albumRepository,
      super(AlbumListLoading()) {
  on<LoadAlbumList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadAlbumListToState();
    } else {
      _mapLoadAlbumListWithDetailsToState();
    }
  });

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

  on<AlbumChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadAlbumListToState();
    } else {
      _mapLoadAlbumListWithDetailsToState();
    }
  });

  on<AddAlbumList>((event, emit) async {
    await _mapAddAlbumListToState(event);
  });

  on<UpdateAlbumList>((event, emit) async {
    await _mapUpdateAlbumListToState(event);
  });

  on<DeleteAlbumList>((event, emit) async {
    await _mapDeleteAlbumListToState(event);
  });

  on<AlbumListUpdated>((event, emit) {
    emit(_mapAlbumListUpdatedToState(event));
  });
}