toInt method

int toInt({
  1. int defaultValue = 0,
})

Converts the string to an integer with a default value if conversion fails.

Implementation

int toInt({int defaultValue = 0}) =>
    isDigit() ? int.parse(this) : defaultValue;