Skip to content

Commit

Permalink
Specify some public lists are immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Jul 19, 2024
1 parent a079cfb commit b789031
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/src/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,26 @@ typedef Pieces = Map<SquareId, Piece>;
typedef ValidMoves = IMap<SquareId, ISet<SquareId>>;

/// Files of the chessboard.
///
/// This is an immutable list of strings from 'a' to 'h'.
const files = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];

/// Ranks of the chessboard.
///
/// This is an immutable list of strings from '1' to '8'.
const ranks = ['1', '2', '3', '4', '5', '6', '7', '8'];

/// All the squares of the chessboard.
///
/// This is an immutable list of strings from 'a1' to 'h8'.
final List<SquareId> allSquares = List.unmodifiable([
for (final f in files)
for (final r in ranks) '$f$r',
]);

/// All the coordinates of the chessboard.
///
/// This is an immutable list of [Coord] from (0, 0) to (7, 7).
final List<Coord> allCoords = List.unmodifiable([
for (final f in files)
for (final r in ranks) Coord.fromSquareId('$f$r'),
Expand Down

0 comments on commit b789031

Please sign in to comment.