getSeatIndex method

int getSeatIndex(
  1. SeatWidgetLayoutConfig layoutConfig,
  2. int row,
  3. int column
)

Implementation

int getSeatIndex(SeatWidgetLayoutConfig layoutConfig, int row, int column) {
  final rows = layoutConfig.rowConfigs.length;
  if (row < 0 || row >= rows) {
    throw ArgumentError("Invalid row index: $row");
  }
  if (column < 0 || column >= layoutConfig.rowConfigs[row].count) {
    throw ArgumentError("Invalid column index: $column");
  }
  final seatsBefore = layoutConfig.rowConfigs.sublist(0, row).fold(0, (sum, config) => sum + config.count);
  return seatsBefore + column;
}