tryParse static method

Rational? tryParse(
  1. String source
)

Parses source as a decimal literal and returns its value as Rational.

As parse except that this method returns null if the input is not valid

Implementation

static Rational? tryParse(String source) {
  try {
    return parse(source);
  } on FormatException {
    return null;
  }
}