parseDecimal function

num? parseDecimal(
  1. String text
)

Parses text as a finite decimal number, or returns null.

Decimal only: no hexadecimal, no NaN, no Infinity. Exposed because an adapter's editor wants the same rule the engine uses, and because a filter operand goes through the same question.

Implementation

num? parseDecimal(String text) {
  final trimmed = text.trim();
  if (trimmed.isEmpty) return null;
  if (!_decimal.hasMatch(trimmed)) return null;
  final parsed = num.tryParse(trimmed);
  if (parsed == null || !parsed.isFinite) return null;
  return parsed;
}