import 'package:flutter_bloc/flutter_bloc.dart'; import 'discount_event.dart'; import 'discount_state.dart'; class DiscountBloc extends Bloc { DiscountBloc() : super(const DiscountState()) { on((event, emit) { List updatedImages = List.from(state.productImages); if (updatedImages.length > event.index) { updatedImages[event.index] = event.imagePath; } else { updatedImages.add(event.imagePath); } emit(state.copyWith(productImages: updatedImages)); }); on((event, emit) { emit(state.copyWith(productName: event.name)); }); on((event, emit) { emit(state.copyWith(discountType: event.type)); }); on((event, emit) { emit(state.copyWith(description: event.description)); }); on((event, emit) { emit(state.copyWith(startDate: event.startDate, endDate: event.endDate)); }); on((event, emit) { emit(state.copyWith(startTime: event.startTime, endTime: event.endTime)); }); on((event, emit) { emit(state.copyWith(price: event.price)); }); on((event, emit) { emit(state.copyWith(discountedPrice: event.price)); }); on((event, emit) { emit(state.copyWith(notificationRadius: event.radius)); }); } }