getInt function

int getInt(
  1. dynamic inputValue, {
  2. int defaultValue = 0,
})

A typed version of getDynamic.

If inputValue is an int, returns it. If inputValue is a null, returns defaultValue.

Implementation

int getInt(dynamic inputValue, {int defaultValue = 0}) {
  if (inputValue == null) {
    return defaultValue;
  } else if (inputValue is String) {
    return int.parse(inputValue);
  } else {
    assert(inputValue is int);
    return inputValue;
  }
}