DocumentListBloc constructor
DocumentListBloc({
- FilterDocumentModels? filter,
- bool? paged,
- String? orderBy,
- bool? descending,
- bool? detailed,
- EliudQuery? eliudQuery,
- required DocumentRepository documentRepository,
- 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));
});
}