Converts the string to an integer with a default value if conversion fails.
int toInt({int defaultValue = 0}) => isDigit() ? int.parse(this) : defaultValue;