maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult legacy(
- MessageHeader header,
- List<
Ed25519HDPublicKey> accountKeys, - String recentBlockhash,
- List<
CompiledInstruction> instructions,
- TResult v0(
- MessageHeader header,
- List<
Ed25519HDPublicKey> accountKeys, - String recentBlockhash,
- List<
CompiledInstruction> instructions, - List<
MessageAddressTableLookup> addressTableLookups,
- 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( MessageHeader header, List<Ed25519HDPublicKey> accountKeys, String recentBlockhash, List<CompiledInstruction> instructions)? legacy,TResult Function( MessageHeader header, List<Ed25519HDPublicKey> accountKeys, String recentBlockhash, List<CompiledInstruction> instructions, List<MessageAddressTableLookup> addressTableLookups)? v0,required TResult orElse(),}) {final _that = this;
switch (_that) {
case CompiledMessageLegacy() when legacy != null:
return legacy(_that.header,_that.accountKeys,_that.recentBlockhash,_that.instructions);case CompiledMessageV0() when v0 != null:
return v0(_that.header,_that.accountKeys,_that.recentBlockhash,_that.instructions,_that.addressTableLookups);case _:
return orElse();
}
}