cast method
Casts the argument to this data type, otherwise throw an ArgumentError.
Implementation
@override
int cast(dynamic value) {
if (value is num) {
if (isSigned) {
return value.toInt().toSigned(bits);
} else {
return value.toInt().toUnsigned(bits);
}
} else if (value is BigInt) {
if (isSigned) {
return value.toSigned(bits).toInt();
} else {
return value.toUnsigned(bits).toInt();
}
} else if (value is Fraction) {
return cast(value.toInt());
} else if (value is String) {
return int.tryParse(value) ?? super.cast(value);
}
return super.cast(value);
}