requireType<T extends AbiType> method
Ensures this type is an instance of T, throwing with a custom message if not.
Parameters
message- Custom error message to include in the exception
Returns
T - This type as T
Throws
ArgumentError- If this type is not an instance of T
Implementation
T requireType<T extends AbiType>(String message) {
if (this is! T) {
throw ArgumentError(
'$message\n'
'Expected ${T.toString()}, got $runtimeType',
);
}
return this as T;
}