maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult implicit()?,
- TResult password()?,
- TResult clientCredentials()?,
- TResult authorizationCode()?,
- required TResult orElse(),
A variant of when that fallback to an orElse callback.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeWhen<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,required TResult orElse(),}) {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 orElse();
}
}