Im new to flutter. I am developing a complaint management app. While logging in there are 2 buttons, sign in (google) and admin sign in. the sign in button is for users and will redirect to home, the admin button will verify with a password and sign in with google. (redirect to admin page) The problem is, once the app is reopened, I am using streambuilder to look for snapshot.data and go to home page. But even for admin its going to home page and not admin after restarting app. I tried to set up a boolean (isLoggedInUserAdmin) and set it 'true' when admin signs in and 'false' when (adminSignsOut). In streambuilder, I am doing
StreamBuilder(
stream: AuthMethods().authChanges,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
if (snapshot.hasData) {
if (AdminLoginScreen.isLoggedInUserAdmin && !AdminComplaintsScreen.hasAdminSignedOut) { //checks if the logged in user is admin and they havent signed out
return AdminHomeScreen();
} else {
return HomeScreen(); //its normal user, so return to home
}
}
return const LoginScreen(); //if no snapshot.data, return to LoginScreen
},
),
Be it Admin or User, once app is restarted, it goes to Normal Home Screen. How do I identify the admin and return him to AdminHomePage ??
Im storing all the users' name in users
collection and admins in admins
collection in firebasefirestore.
Please help me, I need this project to be completed in a week. PLEASE!