FollowingListBloc constructor

FollowingListBloc({
  1. FilterFollowingModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required FollowingRepository followingRepository,
  8. int followingLimit = 5,
})

Implementation

FollowingListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required FollowingRepository followingRepository,
    this.followingLimit = 5})
    : _followingRepository = followingRepository,
      super(FollowingListLoading()) {
  on<LoadFollowingList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadFollowingListToState();
    } else {
      _mapLoadFollowingListWithDetailsToState();
    }
  });

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

  on<FollowingChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadFollowingListToState();
    } else {
      _mapLoadFollowingListWithDetailsToState();
    }
  });

  on<AddFollowingList>((event, emit) async {
    await _mapAddFollowingListToState(event);
  });

  on<UpdateFollowingList>((event, emit) async {
    await _mapUpdateFollowingListToState(event);
  });

  on<DeleteFollowingList>((event, emit) async {
    await _mapDeleteFollowingListToState(event);
  });

  on<FollowingListUpdated>((event, emit) {
    emit(_mapFollowingListUpdatedToState(event));
  });
}