As the title suggests, im only using **signInWithGoogle()** for my user auth, each time i restart the app it went to Login Page even when the user did not log out.

I know this question has been asked plenty of times, im seeing many answers pointing towards using FirebaseAuth streambuilders but i cant seem to get it to work ... Sorry im a beginner and i do not understand much of the documentations too :(

Is there anyway i can direct the users that are logged in to the main page, and those without user data will have to visit LoginPage first?

sign\_in.dart :

```
import 'package:confApp/main.dart';
import 'package:firebase_auth/firebase_auth.dart' as fauth;
import 'package:google_sign_in/google_sign_in.dart';
import 'package:flutter/material.dart';

String name;
String email;
String imageUrlGoogle;
String id;

final fauth.FirebaseAuth _auth = fauth.FirebaseAuth.instance;
final GoogleSignIn googleSignIn = GoogleSignIn();

Future<bool> signInWithGoogle() async {
  final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
  final GoogleSignInAuthentication googleSignInAuthentication =
      await googleSignInAccount.authentication;

  final fauth.AuthCredential credential = fauth.GoogleAuthProvider.credential(
    accessToken: googleSignInAuthentication.accessToken,
    idToken: googleSignInAuthentication.idToken,
  );

  final fauth.UserCredential authResult = await _auth.signInWithCredential(credential);
  final fauth.User user = authResult.user;

  assert(!user.isAnonymous);
  assert(await user.getIdToken() != null);
  assert(user.email != null);
  assert(user.displayName != null);
  assert(user.photoURL != null);
  assert(user.uid != null);

  name = user.displayName;
  email = user.email;
  imageUrlGoogle = user.photoURL;
  id = user.uid;

  final fauth.User currentUser = _auth.currentUser;
  assert(user.uid == currentUser.uid);

  if ( fauth.FirebaseAuth.instance.currentUser != null) {
    return true;
  } else
    return false;

  // return 'signInWithGoogle succeeded: $user';
}

void signOutGoogle() async {
  await googleSignIn.signOut();
  print("User Sign Out");
}

```

Let me know what other codes that you need, ill update the question with the codes. Thanks in advance!