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.

  1. Future<dynamic> initUser() async {
  2. googleUser = await _ensureLoggedInOnStartUp();
  3. if (googleUser == null) {
  4. setState(() {
  5. state.isLoading = false;
  6. });
  7. } else {
  8. // If there is a user, tell Flutter to keep that
  9. // loading screen up Firebase logs in this user.
  10. var firebaseUser = await logIntoFirebase(); // new
  11. }
  12. }

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.