TutorialListBloc constructor

TutorialListBloc({
  1. FilterTutorialModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required TutorialRepository tutorialRepository,
  8. int tutorialLimit = 5,
})

Implementation

TutorialListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required TutorialRepository tutorialRepository,
    this.tutorialLimit = 5})
    : _tutorialRepository = tutorialRepository,
      super(TutorialListLoading()) {
  on<LoadTutorialList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadTutorialListToState();
    } else {
      _mapLoadTutorialListWithDetailsToState();
    }
  });

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

  on<TutorialChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadTutorialListToState();
    } else {
      _mapLoadTutorialListWithDetailsToState();
    }
  });

  on<AddTutorialList>((event, emit) async {
    await _mapAddTutorialListToState(event);
  });

  on<UpdateTutorialList>((event, emit) async {
    await _mapUpdateTutorialListToState(event);
  });

  on<DeleteTutorialList>((event, emit) async {
    await _mapDeleteTutorialListToState(event);
  });

  on<TutorialListUpdated>((event, emit) {
    emit(_mapTutorialListUpdatedToState(event));
  });
}