maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult transfer(
- SplTokenTransferInfo info,
- String type
- TResult transferChecked(
- SplTokenTransferCheckedInfo info,
- String type
- TResult generic(
- dynamic info,
- String type
- 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( SplTokenTransferInfo info, String type)? transfer,TResult Function( SplTokenTransferCheckedInfo info, String type)? transferChecked,TResult Function( dynamic info, String type)? generic,required TResult orElse(),}) {final _that = this;
switch (_that) {
case ParsedSplTokenTransferInstruction() when transfer != null:
return transfer(_that.info,_that.type);case ParsedSplTokenTransferCheckedInstruction() when transferChecked != null:
return transferChecked(_that.info,_that.type);case ParsedSplTokenGenericInstruction() when generic != null:
return generic(_that.info,_that.type);case _:
return orElse();
}
}