when<TResult extends Object?> method
- @optionalTypeArgs
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?>(TResult Function( String epoch, String sequenceNumber, String digest, String networkTotalTransactions, String? previousDigest, EpochRollingGasCostSummary epochRollingGasCostSummary, String timestampMs, List<String> transactions, List<dynamic> checkpointCommitments, String validatorSignature) $default,) {final _that = this;
switch (_that) {
case _Checkpoint():
return $default(_that.epoch,_that.sequenceNumber,_that.digest,_that.networkTotalTransactions,_that.previousDigest,_that.epochRollingGasCostSummary,_that.timestampMs,_that.transactions,_that.checkpointCommitments,_that.validatorSignature);case _:
throw StateError('Unexpected subclass');
}
}