getSquares function

List<Square> getSquares(
  1. Board board
)

Implementation

List<Square> getSquares(Board board) {
  final chess = ch.Chess.fromFEN(board.fen);
  return ch.Chess.SQUARES.keys.map((squareName) {
    return Square(
      board: board,
      name: squareName,
      piece: Option.fromNullable(chess.get(squareName)).map(
        (t) => Piece(
          t.color == ch.Color.WHITE ? BoardColor.WHITE : BoardColor.BLACK,
          PieceType.fromString(t.type.toString()),
        ),
      ),
    );
  }).toList(growable: false);
}