Complex<T extends num, E extends num>.parse constructor
Complex<T extends num, E extends num>.parse (
- String source
Parse source as a Complex literal and return its value.
Accepts an optional sign (+ or -) followed by The imaginary part
A floating-point representation is composed of a mantissa and an optional
The source must not be null.
white-spaces is ignored.
If the source string is not a valid Complex literal, the []
is called with the source as argument, and its return value is
used instead.
Throws a [] if the source string is not valid
and no onError is provided.
Examples of accepted strings:
'3.14'
' 3'
'1+5i'
'.0'
' 1+ 5i '
'6i'
Instead of Complex.parse(string, (string) { ... }),
you should use Complex.tryParse(string) ?? (...).
Implementation
factory Complex.parse(String source) {
final parsed = tryParse<T, E>(source);
assert(parsed != null);
return parsed!;
}