getSquares function

Map<String, Piece?> getSquares(
  1. String fen
)

Implementation

Map<String, Piece?> getSquares(String fen) {
  final boardLogic = chess.Chess.fromFEN(
    fen,
    check_validity: false,
  );
  final result = <String, Piece?>{};
  for (final squareName in chess.Chess.SQUARES.keys) {
    final tempValue = boardLogic.get(squareName);
    if (tempValue == null) {
      result[squareName] = null;
    } else {
      result[squareName] = Piece(
        tempValue.color == chess.Color.WHITE
            ? BoardColor.white
            : BoardColor.black,
        PieceType.fromString(tempValue.type.toString()),
      );
    }
  }
  return result;
}