AppBarListBloc constructor

AppBarListBloc({
  1. FilterAppBarModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required AppBarRepository appBarRepository,
  8. int appBarLimit = 5,
})

Implementation

AppBarListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required AppBarRepository appBarRepository,
    this.appBarLimit = 5})
    : _appBarRepository = appBarRepository,
      super(AppBarListLoading()) {
  on<LoadAppBarList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadAppBarListToState();
    } else {
      _mapLoadAppBarListWithDetailsToState();
    }
  });

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

  on<AppBarChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadAppBarListToState();
    } else {
      _mapLoadAppBarListWithDetailsToState();
    }
  });

  on<AddAppBarList>((event, emit) async {
    await _mapAddAppBarListToState(event);
  });

  on<UpdateAppBarList>((event, emit) async {
    await _mapUpdateAppBarListToState(event);
  });

  on<DeleteAppBarList>((event, emit) async {
    await _mapDeleteAppBarListToState(event);
  });

  on<AppBarListUpdated>((event, emit) {
    emit(_mapAppBarListUpdatedToState(event));
  });
}