# DocumentItemListBloc constructor Null safety

DocumentItemListBloc(

1. {FilterDocumentItemModels? filter,
2. bool? paged,
3. String? orderBy,
4. bool? descending,
5. bool? detailed,
6. EliudQuery? eliudQuery,
7. required DocumentItemRepository documentItemRepository,
8. int documentItemLimit = 5}

)

## Implementation

    DocumentItemListBloc(
        {this.filter,
        this.paged,
        this.orderBy,
        this.descending,
        this.detailed,
        this.eliudQuery,
        required DocumentItemRepository documentItemRepository,
        this.documentItemLimit = 5})
        : _documentItemRepository = documentItemRepository,
          super(DocumentItemListLoading()) {
      on<LoadDocumentItemList>((event, emit) {
        if ((detailed == null) || (!detailed!)) {
          _mapLoadDocumentItemListToState();
        } else {
          _mapLoadDocumentItemListWithDetailsToState();
        }
      });

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

      on<DocumentItemChangeQuery>((event, emit) {
        eliudQuery = event.newQuery;
        if ((detailed == null) || (!detailed!)) {
          _mapLoadDocumentItemListToState();
        } else {
          _mapLoadDocumentItemListWithDetailsToState();
        }
      });

      on<AddDocumentItemList>((event, emit) async {
        await _mapAddDocumentItemListToState(event);
      });

      on<UpdateDocumentItemList>((event, emit) async {
        await _mapUpdateDocumentItemListToState(event);
      });

      on<DeleteDocumentItemList>((event, emit) async {
        await _mapDeleteDocumentItemListToState(event);
      });

      on<DocumentItemListUpdated>((event, emit) {
        emit(_mapDocumentItemListUpdatedToState(event));
      });
    }