whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? transfer(
- ParsedSystemTransferInformation info,
- String type
- TResult? transferChecked(
- ParsedSystemTransferInformation info,
- String type
- TResult? unsupported(
- String type
A variant of when that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function( ParsedSystemTransferInformation info, String type)? transfer,TResult? Function( ParsedSystemTransferInformation info, String type)? transferChecked,TResult? Function( String type)? unsupported,}) {final _that = this;
switch (_that) {
case ParsedSystemTransferInstruction() when transfer != null:
return transfer(_that.info,_that.type);case ParsedSystemTransferCheckedInstruction() when transferChecked != null:
return transferChecked(_that.info,_that.type);case ParsedSystemUnsupportedInstruction() when unsupported != null:
return unsupported(_that.type);case _:
return null;
}
}