toIntSafe method

int toIntSafe()

Implementation

int toIntSafe() {
  final i = this;
  if (i is int) {
    return i;
  } else if (i.isIntegral) {
    return i.toInt();
  } else {
    throw ArgumentError("Number $i could not be safely truncated to an int");
  }
}