Created with <3 with dartpad.dev.
Created
June 14, 2023 15:19
-
-
Save dnys1/8d4f771dff2aa09aa513258f508fd640 to your computer and use it in GitHub Desktop.
bustling-aurora-9307
This file contains hidden or 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
sealed class AuthState {} | |
abstract class AuthUserSignedIn extends AuthState { | |
AuthUser get user; | |
} | |
abstract class AuthUserSignedOut extends AuthState { | |
AuthUser get user; | |
} | |
abstract class AuthSessionRefresh extends AuthState { | |
UserPoolTokens get tokens; | |
AWSCredentials get credentials; | |
} | |
class AuthUser {} | |
class UserPoolTokens {} | |
class AWSCredentials {} | |
Stream<AuthState> authStateChanges() => throw UnimplementedError(); | |
Future<void> main() async { | |
await for (final state in authStateChanges()) { | |
switch (state) { | |
case AuthUserSignedIn(:final user): | |
print('User signed in: $user'); | |
case AuthUserSignedOut(): | |
print('User signed out'); | |
case AuthSessionRefresh(:final tokens, :final credentials): | |
print('New credentials & tokens: $tokens $credentials'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment