Last active
January 14, 2021 07:17
-
-
Save trongdth/b6ae8ce2357eb6cf4e283e00cbf6aace to your computer and use it in GitHub Desktop.
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
import 'package:bloc/bloc.dart'; | |
import 'package:flutter_bloc_back4app/blocs/auth/auth_states.dart'; | |
import 'package:flutter_bloc_back4app/repositories/user_repos.dart'; | |
import 'package:meta/meta.dart'; | |
class AuthCubit extends Cubit<AuthenticationState> { | |
final BaseUserRepository userRepository; | |
AuthCubit({@required this.userRepository}) | |
: assert(userRepository != null), | |
super(AuthenticationUninitialized()); | |
Future<void> appStarted() async { | |
var user = await userRepository.currentUser(); | |
if (user != null) { | |
emit(AuthenticationAuthenticated()); | |
} else { | |
emit(AuthenticationUnauthenticated()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment