whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. String transactionHash,
    2. BigInt? transactionIndex,
    3. String? blockHash,
    4. BigInt? blockNumber,
    5. BigInt gasUsed,
    6. String effectiveGasPrice,
    7. BigInt? blobGasUsed,
    8. String? blobGasPrice,
    9. String from,
    10. String? to,
    11. String? contractAddress,
    )?
)

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;

}
}