toggleSeat method

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

Toggles selection for the seat at row / col. Silently ignores gaps, booked, and disabled seats.

Implementation

void toggleSeat(int row, int col) {
  final state = _grid[row][col].state;
  if (state == SeatState.gap ||
      state == SeatState.booked ||
      state == SeatState.disabled) {
    return;
  }

  final seat = SeatPoint(row, col);
  if (_selectedSeats.contains(seat)) {
    _selectedSeats.remove(seat);
    notifyListeners();
  } else if (_selectedSeats.length < maxSelection) {
    _selectedSeats.add(seat);
    notifyListeners();
  }
}