I have a basic App where I use Email SignIn and SignUp to login to the app. I use a Provider and I'm pushing to either a Login page or a Home page based on the users current state.
When the user Logs In, I want to redirect him to a New Screen (info Page) where he has to fill some other data, which will be saved in Firestore under a document as his UID. (these extra data are just Address/Names/phone.. bla bla)
But, if the user logs out and Logs in again, He shouldn't be redirected to the info Page since he has already submitted that data.
How can I redirect a user if he has NOT submitted the data to the info page and if he has, how can I send him to the Home Page?
This is my Code with Provider and HomeController
@override
Widget build(BuildContext context) {
return Provider(
auth: AuthService(),
db: FirebaseFirestore.instance,
child: MaterialApp(
theme: ThemeData(
primaryColor: Colors.lightGreen[300],
primaryColorDark: Colors.amber,
errorColor: Colors.amber,
hintColor: Colors.grey
),
title: "Farmline.LK",
home: HomeController(),
routes: <String, WidgetBuilder>{
'/home': (BuildContext context) => HomeController(),
'/signUp': (BuildContext context) => FirstView(),
}),
);
}
}
class HomeController extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AuthService auth = Provider.of(context).auth;
return StreamBuilder<String>(
stream: auth.onAuthStateChanged,
builder: (context, AsyncSnapshot<String> snapshot) {
if (snapshot.connectionState == ConnectionState.active) {
final bool signedIn = snapshot.hasData;
return signedIn ? Home() : FirstView();
}
return Container();
},
);
}
}
Thank you so much for your support!