Skip to content

Instantly share code, notes, and snippets.

@stevehobbsdev
Last active March 14, 2022 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevehobbsdev/3531a1a0f9fcca08f645bc979e39c1c4 to your computer and use it in GitHub Desktop.
Save stevehobbsdev/3531a1a0f9fcca08f645bc979e39c1c4 to your computer and use it in GitHub Desktop.
Dart: fluent 1
void main() {
final url = Auth0
.webAuth('elkdanger.eu.auth0.com', '123')
.audience('test')
.buildUrl();
print(url);
}
class WebAuth {
final String domain;
final String clientId;
String? _audience;
WebAuth(this.domain, this.clientId);
audience(String audience) {
_audience = audience;
return this;
}
buildUrl() {
var base = 'https://$domain/authorize';
// Explicit `true` check as nullable expression can't be used as
// a condition.
if (_audience?.isNotEmpty == true) {
base += '?audience=$_audience';
}
return base;
}
}
class Auth0 {
static webAuth(String domain, String clientId) => WebAuth(domain, clientId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment