tryParse static method

RomanNumerals? tryParse(
  1. String input
)

Creates a new instance

Only a basic check of input is performed - namely that it is not empty and contains only valid Roman numerals (as defined in romanDigits).

Implementation

static RomanNumerals? tryParse(String input) {
  // Check for empty string
  if (input.isEmpty) {
    return null;
  }

  for (final c in input.characters) {
    if (!romanDigits.containsKey(c)) {
      return null;
    }
  }
  return RomanNumerals._(input);
}