AppPolicyListBloc constructor

AppPolicyListBloc({
  1. FilterAppPolicyModels? filter,
  2. bool? paged,
  3. String? orderBy,
  4. bool? descending,
  5. bool? detailed,
  6. EliudQuery? eliudQuery,
  7. required AppPolicyRepository appPolicyRepository,
  8. int appPolicyLimit = 5,
})

Implementation

AppPolicyListBloc(
    {this.filter,
    this.paged,
    this.orderBy,
    this.descending,
    this.detailed,
    this.eliudQuery,
    required AppPolicyRepository appPolicyRepository,
    this.appPolicyLimit = 5})
    : _appPolicyRepository = appPolicyRepository,
      super(AppPolicyListLoading()) {
  on<LoadAppPolicyList>((event, emit) {
    if ((detailed == null) || (!detailed!)) {
      _mapLoadAppPolicyListToState();
    } else {
      _mapLoadAppPolicyListWithDetailsToState();
    }
  });

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

  on<AppPolicyChangeQuery>((event, emit) {
    eliudQuery = event.newQuery;
    if ((detailed == null) || (!detailed!)) {
      _mapLoadAppPolicyListToState();
    } else {
      _mapLoadAppPolicyListWithDetailsToState();
    }
  });

  on<AddAppPolicyList>((event, emit) async {
    await _mapAddAppPolicyListToState(event);
  });

  on<UpdateAppPolicyList>((event, emit) async {
    await _mapUpdateAppPolicyListToState(event);
  });

  on<DeleteAppPolicyList>((event, emit) async {
    await _mapDeleteAppPolicyListToState(event);
  });

  on<AppPolicyListUpdated>((event, emit) {
    emit(_mapAppPolicyListUpdatedToState(event));
  });
}