maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult error(
- Error error
- TResult block(
- BlockMsgType msgType,
- String blockHash,
- int blockHeight,
- Int64 blockTimestamp,
- CoinbaseData? coinbaseData,
- TResult tx(
- TxMsgType msgType,
- String txid,
- TxFinalizationReasonType? finalizationReasonType
- required TResult orElse(),
A variant of when that fallback to an orElse callback.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function( pb.Error error)? error,TResult Function( BlockMsgType msgType, String blockHash, int blockHeight, Int64 blockTimestamp, pb.CoinbaseData? coinbaseData)? block,TResult Function( TxMsgType msgType, String txid, TxFinalizationReasonType? finalizationReasonType)? tx,required TResult orElse(),}) {final _that = this;
switch (_that) {
case WsErrorMsg() when error != null:
return error(_that.error);case WsMsgBlockClient() when block != null:
return block(_that.msgType,_that.blockHash,_that.blockHeight,_that.blockTimestamp,_that.coinbaseData);case WsMsgTxClient() when tx != null:
return tx(_that.msgType,_that.txid,_that.finalizationReasonType);case _:
return orElse();
}
}