Auto Login on Startup
If there is a user associated with this account, we want to sign them inwithout them having to do anything. This actually doesn't take much extra code.
1. If a user exists, logIntoFirebase
We just need to add one line to the initUser method in _AppStateContainerState
.
Future<dynamic> initUser() async {
googleUser = await _ensureLoggedInOnStartUp();
if (googleUser == null) {
setState(() {
state.isLoading = false;
});
} else {
// If there is a user, tell Flutter to keep that
// loading screen up Firebase logs in this user.
var firebaseUser = await logIntoFirebase(); // new
}
}
This is the other case in which that method is called, but its already set upto handle it, by checking for a user and switching off isLoading when a user islogged in.
Neat.
当前内容版权归 flutterbyexample.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 flutterbyexample.com .