toInt method

num toInt(
  1. String str,
  2. {int radix = 10}
)

convert the input to an integer, or NAN if the input is not an integer

Implementation

num toInt(String str, {int radix = 10}) {
  try {
    return int.parse(str, radix: radix);
  } catch (e) {
    try {
      return double.parse(str).toInt();
    } catch (e) {
      return double.nan;
    }
  }
}