maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult transfer(
- ParsedSystemTransferInformation info,
- String type
- TResult transferChecked(
- ParsedSystemTransferInformation info,
- String type
- TResult unsupported(
- String type
- required TResult orElse(),
A variant of when that fallback to an orElse callback.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function( ParsedSystemTransferInformation info, String type)? transfer,TResult Function( ParsedSystemTransferInformation info, String type)? transferChecked,TResult Function( String type)? unsupported,required TResult orElse(),}) {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 orElse();
}
}