Decimal constructor

Decimal(
  1. String s
)

Constructs a decimal number from a string ("3.14").

Throws FormatException if parsing fails.

Example

final decimal = Decimal('3');
final decimal = Decimal('3.14');

Implementation

factory Decimal(String s) {
  var result = tryParse(s);
  if (result == null) {
    throw FormatException('Invalid decimal number: "$s"');
  }
  return result;
}