when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<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 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( 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():
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 _:
  throw StateError('Unexpected subclass');

}
}