title: Show different pages for different users in flutter and firestore (role based authentication)
body: <p>I want to develop an app with flutter. The app should use different pages for diffent kinds of users. There are three kinds of users: Club, Company and Fan.
  The problem is, that I'm not able to get to the different pages. My application always stays on the login page. I'm new on working with flutter.</p>
  <p>To manage the information, if a user is logged in or not, I use a StreamBuilder, that checks the auth.State:Changes().
  To read the user information like the role, i use a FirebaseFirestore.instance.</p>
  <p>Here's my class, to manage the authorization.</p>
  <pre><code>class AuthManager {
    final _firestoreInstance = FirebaseFirestore.instance;
  
    Widget homePageManager = const AuthPage();
  
    Widget manageAuth() {
      return StreamBuilder&lt;User?&gt;(
        stream: FirebaseAuth.instance.authStateChanges(),
        builder: (context, snapshot) {
          if (snapshot.hasData) {
            _firestoreInstance
                .collection('Users')
                .doc(snapshot.data?.uid)
                .get()
                .then((DocumentSnapshot docs) {
              final data = docs.data() as Map&lt;String, dynamic&gt;;
              final role = data['role'];
  
              if (role == 'Club') {
                homePageManager = const ClubHomepage();
              } else if (role == 'Company') {
                homePageManager = const CompanyHomepage();
              } else if (role == 'Fan') {
                homePageManager = const FanHomepage();
              }
            });
            return homePageManager;
          } else {
            print('test');
            return const AuthPage();
          }
        },
      );
    }
  
    signOut() {
      FirebaseAuth.instance.signOut();
    }
  }
  </code></pre>
  <p>Here's my method, to log in:</p>
  <pre><code>Future signIn() async {
  showDialog(
    context: context,
    builder: (context) =&gt; const Center(child: CircularProgressIndicator()),
  );
  
  try {
    final newUser = await _authInstance.signInWithEmailAndPassword(
      email: emailController.text.trim(),
      password: passwordController.text.trim(),
    );
  
  } on FirebaseAuthException catch (e) {
    print(e);
  
    Utils.showSnackBar(e.message);
  }
  
  navigatorKey.currentState!.popUntil((route) =&gt; route.isFirst);
  </code></pre>
  <p>}</p>
  <p>If you need more information, please let me know.</p>
  <p>Thank you!</p>