SimpleTextListBloc constructor

SimpleTextListBloc({
  1. FilterSimpleTextModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required SimpleTextRepository simpleTextRepository,
  8. int simpleTextLimit = 5,
})

Implementation

SimpleTextListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required SimpleTextRepository simpleTextRepository,
    this.simpleTextLimit = 5})
    : _simpleTextRepository = simpleTextRepository,
      super(SimpleTextListLoading()) {
  on<LoadSimpleTextList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadSimpleTextListToState();
    } else {
      _mapLoadSimpleTextListWithDetailsToState();
    }
  });

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

  on<SimpleTextChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadSimpleTextListToState();
    } else {
      _mapLoadSimpleTextListWithDetailsToState();
    }
  });

  on<AddSimpleTextList>((event, emit) async {
    await _mapAddSimpleTextListToState(event);
  });

  on<UpdateSimpleTextList>((event, emit) async {
    await _mapUpdateSimpleTextListToState(event);
  });

  on<DeleteSimpleTextList>((event, emit) async {
    await _mapDeleteSimpleTextListToState(event);
  });

  on<SimpleTextListUpdated>((event, emit) {
    emit(_mapSimpleTextListUpdatedToState(event));
  });
}