parseInt method

int parseInt()

Implementation

int parseInt() {
  try {
    if (isNullOrEmptyOrZero()) return 0;

    if (this is int) return this as int;
    if (this is double) return (this as double).toInt();
    if (this is bool) return (this as bool) ? 1 : 0;

    final str = toString().trim();
    if (str.equals("+") || str.equals("-")) return 0;

    return int.parse(str.split(".")[0]);
  } catch (e) {
    return 0;
  }
}