toInt static method
Implementation
static int? toInt(v, {int? defaultValue}) {
if (v == null) return defaultValue;
if (v is int) return v;
if (v is num) return v.toInt();
if (v is String) return int.tryParse(v) ?? defaultValue;
if (defaultValue != null) return defaultValue;
throw Exception('Trying to convert a non-integer to int!');
}