File.fromName constructor

File.fromName(
  1. String algebraic
)

Gets a File from its name in algebraic notation.

Throws a FormatException if the algebraic notation is invalid.

Implementation

factory File.fromName(String algebraic) {
  final file = algebraic.codeUnitAt(0) - 97;
  if (file < 0 || file > 7) {
    throw FormatException('Invalid algebraic notation: $algebraic');
  }
  return File(file);
}