CollageBloc constructor

CollageBloc({
  1. required BuildContext context,
  2. required CollageType collageType,
  3. required String path,
  4. List<Images>? listOfImages,
})

Implementation

CollageBloc(
    {required this.context,
    required this.collageType,
    required this.path,
    this.listOfImages})
    : super(InitialState()) {
  on<CheckPermissionEvent>((event, emit) =>
      checkPermission(event.isFromPicker, event.permissionType, event.index));
  on<AllowPermissionEvent>((event, emit) {
    if (event.isFromPicker) {
      openPicker(event.permissionType, event.index);
    } else {
      emit(LoadImageState());
      loadImages(path, getImageCount());
    }
  });
  on<AskPermissionEvent>((event, emit) =>
      askPermission(event.isFromPicker, event.permissionType, event.index));

  on<DenyPermissionEvent>((event, emit) {
    showSnackBar();
    if (!event.isFromPicker) {
      emit(PermissionDeniedState());
    }
  });

  on<ImageListEvent>((event, emit) {
    emit(LoadImageState());
    emit(ImageListState(images: event.imageList));
  });
}