whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. String clientId,
    2. String applicationType,
    3. String clientName,
    4. String clientUri,
    5. bool dpopBoundAccessTokens,
    6. List<String> grantTypes,
    7. List<String> redirectUrisOLD,
    8. List<String> redirectUris,
    9. List<String> responseTypes,
    10. String scope,
    11. String tokenEndpointAuthMethod,
    )?
)

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( String clientId,  String applicationType,  String clientName,  String clientUri,  bool dpopBoundAccessTokens,  List<String> grantTypes, @JsonKey(name: 'redirect_uris_OLD')  List<String> redirectUrisOLD,  List<String> redirectUris,  List<String> responseTypes,  String scope,  String tokenEndpointAuthMethod)?  $default,) {final _that = this;
switch (_that) {
case _OAuthClientMetadata() when $default != null:
return $default(_that.clientId,_that.applicationType,_that.clientName,_that.clientUri,_that.dpopBoundAccessTokens,_that.grantTypes,_that.redirectUrisOLD,_that.redirectUris,_that.responseTypes,_that.scope,_that.tokenEndpointAuthMethod);case _:
  return null;

}
}