tryParse method
- String input
Parses a string containing a number literal into a number.
Like parse except that this function returns null for invalid inputs instead of throwing.
Implementation
static num? tryParse(String input) {
String source = input.trim();
// TODO(lrn): Optimize to detect format and result type in one check.
return int.tryParse(source) ?? double.tryParse(source);
}
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-core/num/tryParse.html