cast method
Casts the argument to this data type, otherwise throw an ArgumentError.
Implementation
@override
Quaternion cast(dynamic value) {
if (value is Quaternion) {
return value;
} else if (value is num) {
return Quaternion(value);
} else if (value is BigInt) {
return Quaternion(value.toDouble());
} else if (value is Fraction) {
return Quaternion(value.toDouble());
} else if (value is Complex) {
return Quaternion(value.a, value.b);
} else if (value is String) {
return Quaternion.tryParse(value) ?? super.cast(value);
}
return super.cast(value);
}