toggleSeat method

void toggleSeat(
  1. int row,
  2. int col
)

Toggles the selection state of a seat at row and col.

Implementation

void toggleSeat(int row, int col) {
  final val = seatGrid[row][col];

  // 1. Validation: Ignore clicks on gaps, booked, or disabled seats
  if (val == 0 || val == 2 || val == 3) return;

  final seat = SeatPoint(row, col);

  // 2. Logic: Standard Toggle
  if (_selectedSeats.contains(seat)) {
    // Always allow deselecting
    _selectedSeats.remove(seat);
    notifyListeners();
  } else {
    // Only add if we haven't reached the limit
    if (_selectedSeats.length < maxSelection) {
      _selectedSeats.add(seat);
      notifyListeners();
    }
  }
}