when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- int lamports,
- String owner,
- AccountData? data,
- bool executable,
- BigInt rentEpoch,
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( int lamports, String owner, AccountData? data, bool executable, @JsonKey(fromJson: bigIntFromJson) BigInt rentEpoch) $default,) {final _that = this;
switch (_that) {
case _Account():
return $default(_that.lamports,_that.owner,_that.data,_that.executable,_that.rentEpoch);case _:
throw StateError('Unexpected subclass');
}
}