Skip to content

Instantly share code, notes, and snippets.

@dnys1
Created June 14, 2023 15:19
Show Gist options
  • Save dnys1/8d4f771dff2aa09aa513258f508fd640 to your computer and use it in GitHub Desktop.
Save dnys1/8d4f771dff2aa09aa513258f508fd640 to your computer and use it in GitHub Desktop.
bustling-aurora-9307

bustling-aurora-9307

Created with <3 with dartpad.dev.

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