when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>({
  1. required TResult transfer(
    1. ParsedSystemTransferInformation info,
    2. String type
    ),
  2. required TResult transferChecked(
    1. ParsedSystemTransferInformation info,
    2. String type
    ),
  3. required TResult unsupported(
    1. 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);}
}