tryParseNum static method

num? tryParseNum(
  1. dynamic v
)

解析num,失败返回null

Implementation

static num? tryParseNum(dynamic v) {
  if (v is IntX) {
    return v.toInt();
  } else if (v is int) {
    return v;
  } else if (v is double) {
    return v;
  } else if (v is num) {
    return v;
  } else if (v is String) {
    return num.tryParse(v);
  }
  return null;
}