ChatListBloc constructor

ChatListBloc({
  1. FilterChatModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required ChatRepository chatRepository,
  8. int chatLimit = 5,
})

Implementation

ChatListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required ChatRepository chatRepository,
    this.chatLimit = 5})
    : _chatRepository = chatRepository,
      super(ChatListLoading()) {
  on<LoadChatList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadChatListToState();
    } else {
      _mapLoadChatListWithDetailsToState();
    }
  });

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

  on<ChatChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadChatListToState();
    } else {
      _mapLoadChatListWithDetailsToState();
    }
  });

  on<AddChatList>((event, emit) async {
    await _mapAddChatListToState(event);
  });

  on<UpdateChatList>((event, emit) async {
    await _mapUpdateChatListToState(event);
  });

  on<DeleteChatList>((event, emit) async {
    await _mapDeleteChatListToState(event);
  });

  on<ChatListUpdated>((event, emit) {
    emit(_mapChatListUpdatedToState(event));
  });
}