toInt property

int get toInt

Parses the string to an int. Returns 0 if parsing fails.

Example:

'42'.toInt // 42
'abc'.toInt // 0

Implementation

int get toInt => int.tryParse(this) ?? 0;