toNum property
num?
toNum
Converts the string to a num (which can be either int or double). Returns null if the conversion fails.
Example:
print('123'.toNum); // Output: 123
print('123.45'.toNum); // Output: 123.45
print('abc'.toNum); // Output: null
Implementation
num? get toNum => num.tryParse(this);