whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>()
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( String transactionHash, BigInt? transactionIndex, String? blockHash, BigInt? blockNumber, BigInt gasUsed, String effectiveGasPrice, BigInt? blobGasUsed, String? blobGasPrice, String from, String? to, String? contractAddress)? $default,) {final _that = this;
switch (_that) {
case _TransactionReceiptCompat() when $default != null:
return $default(_that.transactionHash,_that.transactionIndex,_that.blockHash,_that.blockNumber,_that.gasUsed,_that.effectiveGasPrice,_that.blobGasUsed,_that.blobGasPrice,_that.from,_that.to,_that.contractAddress);case _:
return null;
}
}