parse static method

A1 parse(
  1. String input
)

Parses a string containing an A1 literal into an A1.

If that fails, too, it throws a FormatException.

Rather than throwing and immediately catching the FormatException, instead use tryParse to handle a potential parsing error.

Examples:

A1 a1 = A1.parse('a1'); //A1
a1 = A1.parse('b2');  // B2
a1 = A1.parse(' B345'); // B324
a1 = A1.parse('A0'); // FormatException
a1 = A1.parse('1A'); // FormatException
a1 = A1.parse('A-1'); // FormatException

Implementation

static A1 parse(String input) {
  final result = tryParse(input);
  if (result == null) {
    throw FormatException('Invalid A1 notation $input', input, 0);
  }
  return result;
}