20 lines
784 B
Dart
20 lines
784 B
Dart
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));
|
|
// در اینجا میتوانید لاگیک مربوط به ارسال درخواست به API را نیز اضافه کنید
|
|
}
|
|
|
|
// متد برای بررسی اینکه آیا یک محصول خاص رزرو شده است یا نه
|
|
bool isProductReserved(String productId) {
|
|
return state.reservedProductIds.contains(productId);
|
|
}
|
|
} |