tryParse static method

Decimal? tryParse(
  1. String source
)

Parses source as a decimal literal and returns its value as Decimal, or null if the parsing fails.

Implementation

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