ChatDashboardListBloc constructor

ChatDashboardListBloc({
  1. FilterChatDashboardModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required ChatDashboardRepository chatDashboardRepository,
  8. int chatDashboardLimit = 5,
})

Implementation

ChatDashboardListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required ChatDashboardRepository chatDashboardRepository,
    this.chatDashboardLimit = 5})
    : _chatDashboardRepository = chatDashboardRepository,
      super(ChatDashboardListLoading()) {
  on<LoadChatDashboardList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadChatDashboardListToState();
    } else {
      _mapLoadChatDashboardListWithDetailsToState();
    }
  });

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

  on<ChatDashboardChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadChatDashboardListToState();
    } else {
      _mapLoadChatDashboardListWithDetailsToState();
    }
  });

  on<AddChatDashboardList>((event, emit) async {
    await _mapAddChatDashboardListToState(event);
  });

  on<UpdateChatDashboardList>((event, emit) async {
    await _mapUpdateChatDashboardListToState(event);
  });

  on<DeleteChatDashboardList>((event, emit) async {
    await _mapDeleteChatDashboardListToState(event);
  });

  on<ChatDashboardListUpdated>((event, emit) {
    emit(_mapChatDashboardListUpdatedToState(event));
  });
}