whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? account(
- SplTokenAccountDataInfo info,
- String type,
- String? accountType
- TResult? mint(
- MintAccountDataInfo info,
- String type,
- String? accountType
- TResult? unknown(
- String type
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( SplTokenAccountDataInfo info, String type, String? accountType)? account,TResult? Function( MintAccountDataInfo info, String type, String? accountType)? mint,TResult? Function( String type)? unknown,}) {final _that = this;
switch (_that) {
case TokenAccountData() when account != null:
return account(_that.info,_that.type,_that.accountType);case MintAccountData() when mint != null:
return mint(_that.info,_that.type,_that.accountType);case UnknownAccountData() when unknown != null:
return unknown(_that.type);case _:
return null;
}
}