tryParse static method

FdcDecimal? tryParse(
  1. String text, {
  2. int? scale,
  3. String decimalSeparator = '.',
  4. String? thousandSeparator,
  5. bool negative = true,
  6. bool allowCommaDecimalFallback = true,
})

Parses user text using optional localized separators and stores it at the requested scale.

Implementation

static FdcDecimal? tryParse(
  String text, {
  int? scale,
  String decimalSeparator = '.',
  String? thousandSeparator,
  bool negative = true,
  bool allowCommaDecimalFallback = true,
}) {
  final normalized = FdcDecimalMath.normalizeTextForParsing(
    text,
    decimalSeparator: decimalSeparator,
    thousandSeparator: thousandSeparator,
    negative: negative,
    allowCommaDecimalFallback: allowCommaDecimalFallback,
  );
  if (normalized == null || normalized.isEmpty) {
    return null;
  }
  final effectiveScale = scale ?? _fractionScale(normalized);
  return tryParseNormalized(normalized, scale: effectiveScale);
}