19 lines
582 B
Dart
19 lines
582 B
Dart
// ignore: depend_on_referenced_packages
|
|
import 'package:bloc/bloc.dart';
|
|
|
|
part 'reservation_state.dart';
|
|
|
|
class ReservationCubit extends Cubit<ReservationState> {
|
|
ReservationCubit() : super(const ReservationState());
|
|
|
|
void reserveProduct(String productId) {
|
|
if (state.reservedProductIds.contains(productId)) return;
|
|
|
|
final updatedList = List<String>.from(state.reservedProductIds)..add(productId);
|
|
emit(state.copyWith(reservedProductIds: updatedList));
|
|
}
|
|
|
|
bool isProductReserved(String productId) {
|
|
return state.reservedProductIds.contains(productId);
|
|
}
|
|
} |