parseInt static method
Tries to parse an int.
- Returns
def
ifvalue
is invalid.
Implementation
static int? parseInt(Object? value, [int? def]) {
if (value == null) return def;
if (value is int) {
return value;
} else if (value is num) {
return value.toInt();
} else if (value is DateTime) {
return value.millisecondsSinceEpoch;
} else {
var n = _parseNumString(value);
return n?.toInt() ?? def;
}
}