when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<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 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 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():
return $default(_that.transactionHash,_that.transactionIndex,_that.blockHash,_that.blockNumber,_that.gasUsed,_that.effectiveGasPrice,_that.blobGasUsed,_that.blobGasPrice,_that.from,_that.to,_that.contractAddress);}
}