toTryInt method

int? toTryInt()

Tries to parse the string to an integer. Returns null if parsing fails.

Example:

'123'.toTryInt(); // returns 123
'abc'.toTryInt(); // returns null
value?.toString().toTryInt(); // returns null or int value

Implementation

int? toTryInt() => int.tryParse(this);