whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. int lamports,
    2. String owner,
    3. AccountData? data,
    4. bool executable,
    5. BigInt rentEpoch,
    )?
)

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( int lamports,  String owner,  AccountData? data,  bool executable, @JsonKey(fromJson: bigIntFromJson)  BigInt rentEpoch)?  $default,) {final _that = this;
switch (_that) {
case _Account() when $default != null:
return $default(_that.lamports,_that.owner,_that.data,_that.executable,_that.rentEpoch);case _:
  return null;

}
}