PostListBloc constructor
PostListBloc({
- FilterPostModels? filter,
- bool? paged,
- String? orderBy,
- bool? descending,
- bool? detailed,
- EliudQuery? eliudQuery,
- required PostRepository postRepository,
- int postLimit = 5,
Implementation
PostListBloc(
{this.filter,
this.paged,
this.orderBy,
this.descending,
this.detailed,
this.eliudQuery,
required PostRepository postRepository,
this.postLimit = 5})
: _postRepository = postRepository,
super(PostListLoading()) {
on<LoadPostList>((event, emit) {
if ((detailed == null) || (!detailed!)) {
_mapLoadPostListToState();
} else {
_mapLoadPostListWithDetailsToState();
}
});
on<NewPage>((event, emit) {
pages = pages +
1; // it doesn't matter so much if we increase pages beyond the end
_mapLoadPostListWithDetailsToState();
});
on<PostChangeQuery>((event, emit) {
eliudQuery = event.newQuery;
if ((detailed == null) || (!detailed!)) {
_mapLoadPostListToState();
} else {
_mapLoadPostListWithDetailsToState();
}
});
on<AddPostList>((event, emit) async {
await _mapAddPostListToState(event);
});
on<UpdatePostList>((event, emit) async {
await _mapUpdatePostListToState(event);
});
on<DeletePostList>((event, emit) async {
await _mapDeletePostListToState(event);
});
on<PostListUpdated>((event, emit) {
emit(_mapPostListUpdatedToState(event));
});
}