toInt property

int get toInt

Converts the string to an integer. Returns null if the conversion fails.

Example:

print('12'.toInt); // Output: 12
print('12.34'.toInt); // Output: 12 (truncated conversion)
print('abc'.toInt); // Output: 0

Implementation

int get toInt => toNum.toInt();