whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? implicit()?,
- TResult? password()?,
- TResult? clientCredentials()?,
- TResult? authorizationCode()?,
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 authorizationUrl, String? refreshUrl, Map<String, String> scopes)? implicit,TResult? Function( String tokenUrl, String? refreshUrl, Map<String, String> scopes)? password,TResult? Function( String tokenUrl, String? refreshUrl, Map<String, String> scopes)? clientCredentials,TResult? Function( String authorizationUrl, String tokenUrl, String? refreshUrl, Map<String, String> scopes)? authorizationCode,}) {final _that = this;
switch (_that) {
case _OAuthFlowImplicit() when implicit != null:
return implicit(_that.authorizationUrl,_that.refreshUrl,_that.scopes);case _OAuthFlowPassword() when password != null:
return password(_that.tokenUrl,_that.refreshUrl,_that.scopes);case _OAuthFlowClientCredentials() when clientCredentials != null:
return clientCredentials(_that.tokenUrl,_that.refreshUrl,_that.scopes);case _OAuthFlowAuthorizationCode() when authorizationCode != null:
return authorizationCode(_that.authorizationUrl,_that.tokenUrl,_that.refreshUrl,_that.scopes);case _:
return null;
}
}