when<TResult extends Object?> method
- @optionalTypeArgs
- required TResult transfer(
- ParsedSystemTransferInformation info,
- String type
- required TResult transferChecked(
- ParsedSystemTransferInformation info,
- String type
- required TResult unsupported(
- 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( ParsedSystemTransferInformation info, String type) transfer,required TResult Function( ParsedSystemTransferInformation info, String type) transferChecked,required TResult Function( String type) unsupported,}) {final _that = this;
switch (_that) {
case ParsedSystemTransferInstruction():
return transfer(_that.info,_that.type);case ParsedSystemTransferCheckedInstruction():
return transferChecked(_that.info,_that.type);case ParsedSystemUnsupportedInstruction():
return unsupported(_that.type);}
}