whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? evm(
- String id,
- String chainId,
- String method,
- List<
EvmTransactionParams> params,
- TResult? solana(
- String id,
- String chainId,
- String method,
- SolanaTransactionParams params,
- TResult? tron(
- String id,
- String chainId,
- String method,
- TronTransactionParams params,
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 id, String chainId, String method, List<EvmTransactionParams> params)? evm,TResult? Function( String id, String chainId, String method, SolanaTransactionParams params)? solana,TResult? Function( String id, String chainId, String method, TronTransactionParams params)? tron,}) {final _that = this;
switch (_that) {
case EvmTransactionRpc() when evm != null:
return evm(_that.id,_that.chainId,_that.method,_that.params);case SolanaTransactionRpc() when solana != null:
return solana(_that.id,_that.chainId,_that.method,_that.params);case TronTransactionRpc() when tron != null:
return tron(_that.id,_that.chainId,_that.method,_that.params);case _:
return null;
}
}