getMoveSan method

Move? getMoveSan(
  1. String san, {
  2. bool checks = false,
})

Gets a move from a SAN string, e.g. 'Nxf3', 'e4', 'O-O-O'. If checks is false, the '+' or '#' part of the SAN string will not be computed, which vastly increases efficiency in cases like PGN parsing.\

Implementation

Move? getMoveSan(String san, {bool checks = false}) {
  if (!checks) {
    san = san.replaceAll('#', '').replaceAll('+', '');
  }
  List<Move> moves = generateLegalMoves();
  Move? match = moves
      .firstWhereOrNull((m) => toSan(m, moves: moves, checks: checks) == san);
  return match;
}