Last active
March 14, 2022 13:35
-
-
Save stevehobbsdev/3531a1a0f9fcca08f645bc979e39c1c4 to your computer and use it in GitHub Desktop.
Dart: fluent 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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