ProfileListBloc constructor

ProfileListBloc({
  1. FilterProfileModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required ProfileRepository profileRepository,
  8. int profileLimit = 5,
})

Implementation

ProfileListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required ProfileRepository profileRepository,
    this.profileLimit = 5})
    : _profileRepository = profileRepository,
      super(ProfileListLoading()) {
  on<LoadProfileList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadProfileListToState();
    } else {
      _mapLoadProfileListWithDetailsToState();
    }
  });

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

  on<ProfileChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadProfileListToState();
    } else {
      _mapLoadProfileListWithDetailsToState();
    }
  });

  on<AddProfileList>((event, emit) async {
    await _mapAddProfileListToState(event);
  });

  on<UpdateProfileList>((event, emit) async {
    await _mapUpdateProfileListToState(event);
  });

  on<DeleteProfileList>((event, emit) async {
    await _mapDeleteProfileListToState(event);
  });

  on<ProfileListUpdated>((event, emit) {
    emit(_mapProfileListUpdatedToState(event));
  });
}