DocumentListBloc constructor

DocumentListBloc({
  1. FilterDocumentModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required DocumentRepository documentRepository,
  8. int documentLimit = 5,
})

Implementation

DocumentListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required DocumentRepository documentRepository,
    this.documentLimit = 5})
    : _documentRepository = documentRepository,
      super(DocumentListLoading()) {
  on<LoadDocumentList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadDocumentListToState();
    } else {
      _mapLoadDocumentListWithDetailsToState();
    }
  });

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

  on<DocumentChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadDocumentListToState();
    } else {
      _mapLoadDocumentListWithDetailsToState();
    }
  });

  on<AddDocumentList>((event, emit) async {
    await _mapAddDocumentListToState(event);
  });

  on<UpdateDocumentList>((event, emit) async {
    await _mapUpdateDocumentListToState(event);
  });

  on<DeleteDocumentList>((event, emit) async {
    await _mapDeleteDocumentListToState(event);
  });

  on<DocumentListUpdated>((event, emit) {
    emit(_mapDocumentListUpdatedToState(event));
  });
}