when<TResult extends Object?> method
- @optionalTypeArgs
- required TResult transfer(
- SplTokenTransferInfo info,
- String type
- required TResult transferChecked(
- SplTokenTransferCheckedInfo info,
- String type
- required TResult generic(
- dynamic info,
- String type
A switch-like method, using callbacks.
As opposed to map, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( SplTokenTransferInfo info, String type) transfer,required TResult Function( SplTokenTransferCheckedInfo info, String type) transferChecked,required TResult Function( dynamic info, String type) generic,}) {final _that = this;
switch (_that) {
case ParsedSplTokenTransferInstruction():
return transfer(_that.info,_that.type);case ParsedSplTokenTransferCheckedInstruction():
return transferChecked(_that.info,_that.type);case ParsedSplTokenGenericInstruction():
return generic(_that.info,_that.type);}
}