tryCastToInt method

int? tryCastToInt()

Implementation

int? tryCastToInt() {
  if (this == null) {
    return null;
  }
  if (this is num) {
    return (this as num).toInt();
  }
  if (this is int) {
    return this as int;
  }
  return int.tryParse(this.toString().trim());
}