toNum property
num
get
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: 0
Implementation
num get toNum => num.tryParse(this) ?? 0;