tryParse static method Null safety
- String source
override
Parse source
as a double literal and return its value.
Like parse, except that this function returns null
for invalid inputs
instead of throwing.
Example:
var value = double.tryParse('3.14'); // 3.14
value = double.tryParse(' 3.14 \xA0'); // 3.14
value = double.tryParse('0.'); // 0.0
value = double.tryParse('.0'); // 0.0
value = double.tryParse('-1.e3'); // -1000.0
value = double.tryParse('1234E+7'); // 12340000000.0
value = double.tryParse('+.12e-9'); // 1.2e-10
value = double.tryParse('-NaN'); // NaN
value = double.tryParse('0xFF'); // null
value = double.tryParse(double.infinity.toString()); // Infinity
Implementation
external static double? tryParse(String source);