# GridListBloc constructor Null safety

GridListBloc(

1. {FilterGridModels? filter,
2. bool? paged,
3. String? orderBy,
4. bool? descending,
5. bool? detailed,
6. EliudQuery? eliudQuery,
7. required GridRepository gridRepository,
8. int gridLimit = 5}

)

## Implementation

    GridListBloc(
        {this.filter,
        this.paged,
        this.orderBy,
        this.descending,
        this.detailed,
        this.eliudQuery,
        required GridRepository gridRepository,
        this.gridLimit = 5})
        : _gridRepository = gridRepository,
          super(GridListLoading()) {
      on<LoadGridList>((event, emit) {
        if ((detailed == null) || (!detailed!)) {
          _mapLoadGridListToState();
        } else {
          _mapLoadGridListWithDetailsToState();
        }
      });

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

      on<GridChangeQuery>((event, emit) {
        eliudQuery = event.newQuery;
        if ((detailed == null) || (!detailed!)) {
          _mapLoadGridListToState();
        } else {
          _mapLoadGridListWithDetailsToState();
        }
      });

      on<AddGridList>((event, emit) async {
        await _mapAddGridListToState(event);
      });

      on<UpdateGridList>((event, emit) async {
        await _mapUpdateGridListToState(event);
      });

      on<DeleteGridList>((event, emit) async {
        await _mapDeleteGridListToState(event);
      });

      on<GridListUpdated>((event, emit) {
        emit(_mapGridListUpdatedToState(event));
      });
    }