DialogListBloc constructor

DialogListBloc({
  1. FilterDialogModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required DialogRepository dialogRepository,
  8. int dialogLimit = 5,
})

Implementation

DialogListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required DialogRepository dialogRepository,
    this.dialogLimit = 5})
    : _dialogRepository = dialogRepository,
      super(DialogListLoading()) {
  on<LoadDialogList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadDialogListToState();
    } else {
      _mapLoadDialogListWithDetailsToState();
    }
  });

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

  on<DialogChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadDialogListToState();
    } else {
      _mapLoadDialogListWithDetailsToState();
    }
  });

  on<AddDialogList>((event, emit) async {
    await _mapAddDialogListToState(event);
  });

  on<UpdateDialogList>((event, emit) async {
    await _mapUpdateDialogListToState(event);
  });

  on<DeleteDialogList>((event, emit) async {
    await _mapDeleteDialogListToState(event);
  });

  on<DialogListUpdated>((event, emit) {
    emit(_mapDialogListUpdatedToState(event));
  });
}