mapOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
  1. TResult? transfer(
    1. ParsedSystemTransferInstruction value
    )?,
  2. TResult? transferChecked(
    1. ParsedSystemTransferCheckedInstruction value
    )?,
  3. TResult? unsupported(
    1. ParsedSystemUnsupportedInstruction value
    )?,
})

A variant of map that fallback to returning null.

It is equivalent to doing:

switch (sealedClass) {
  case final Subclass value:
    return ...;
  case _:
    return null;
}

Implementation

@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( ParsedSystemTransferInstruction value)?  transfer,TResult? Function( ParsedSystemTransferCheckedInstruction value)?  transferChecked,TResult? Function( ParsedSystemUnsupportedInstruction value)?  unsupported,}){
final _that = this;
switch (_that) {
case ParsedSystemTransferInstruction() when transfer != null:
return transfer(_that);case ParsedSystemTransferCheckedInstruction() when transferChecked != null:
return transferChecked(_that);case ParsedSystemUnsupportedInstruction() when unsupported != null:
return unsupported(_that);case _:
  return null;

}
}