@@ -128,7 +128,29 @@ class ServiceFilesBloc extends Bloc<ServiceFilesEvent, ServiceFilesState> {
|
||||
FutureOr<void> _onUploadServiceFiles(
|
||||
UploadServiceFilesEvent event,
|
||||
Emitter<ServiceFilesState> emit,
|
||||
) {}
|
||||
) async {
|
||||
if (event.pickedFiles == null && event.photos == null) return;
|
||||
if (event.pickedFiles!.isEmpty && event.photos!.isEmpty) return;
|
||||
|
||||
// BIVIO 2: PRATICA ESISTENTE (Abbiamo l'ID
|
||||
emit(state.copyWith(status: ServiceFilesStatus.uploading));
|
||||
try {
|
||||
// Logica identica a quella che abbiamo fatto per i clienti
|
||||
if (event.pickedFiles != null && event.pickedFiles!.isNotEmpty) {
|
||||
for (var file in event.pickedFiles!) {
|
||||
await _repository.uploadAndRegisterServiceFile(
|
||||
serviceId: serviceId!,
|
||||
pickedFile: file,
|
||||
);
|
||||
}
|
||||
}
|
||||
emit(state.copyWith(status: ServiceFilesStatus.success));
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(status: ServiceFilesStatus.failure, error: e.toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _onDeleteServiceFiles(
|
||||
DeleteServiceFilesEvent event,
|
||||
|
||||
@@ -33,12 +33,12 @@ class AddServiceFilesEvent extends ServiceFilesEvent {
|
||||
}
|
||||
|
||||
class UploadServiceFilesEvent extends ServiceFilesEvent {
|
||||
final PlatformFile? pickedFile;
|
||||
final File? photo;
|
||||
const UploadServiceFilesEvent({this.pickedFile, this.photo});
|
||||
final List<PlatformFile>? pickedFiles;
|
||||
final List<File>? photos;
|
||||
const UploadServiceFilesEvent({this.pickedFiles, this.photos});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [pickedFile, photo];
|
||||
List<Object?> get props => [pickedFiles, photos];
|
||||
}
|
||||
|
||||
class DeleteServiceFilesEvent extends ServiceFilesEvent {}
|
||||
|
||||
Reference in New Issue
Block a user