NotificationListBloc constructor

NotificationListBloc({
  1. FilterNotificationModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required NotificationRepository notificationRepository,
  8. int notificationLimit = 5,
})

Implementation

NotificationListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required NotificationRepository notificationRepository,
    this.notificationLimit = 5})
    : _notificationRepository = notificationRepository,
      super(NotificationListLoading()) {
  on<LoadNotificationList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadNotificationListToState();
    } else {
      _mapLoadNotificationListWithDetailsToState();
    }
  });

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

  on<NotificationChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadNotificationListToState();
    } else {
      _mapLoadNotificationListWithDetailsToState();
    }
  });

  on<AddNotificationList>((event, emit) async {
    await _mapAddNotificationListToState(event);
  });

  on<UpdateNotificationList>((event, emit) async {
    await _mapUpdateNotificationListToState(event);
  });

  on<DeleteNotificationList>((event, emit) async {
    await _mapDeleteNotificationListToState(event);
  });

  on<NotificationListUpdated>((event, emit) {
    emit(_mapNotificationListUpdatedToState(event));
  });
}