toInt method

int toInt()

parse dynamic to int used when parsing json

Implementation

int toInt() {
  if (this == null) return 0;
  if (this is int) return this;
  if (this is double) return this.round();
  if (this is String) return int.parse(this);
  return 0;
}