toInt method

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

Return int value of given string

Implementation

int toInt({int defaultValue = 0}) {
  if (this == null) return defaultValue;

  if (isDigit()) {
    return int.parse(this!);
  } else {
    return defaultValue;
  }
}