Replies: 2 comments
-
Hi, did you find any solution to this? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Solution found:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello Team -
Are there any example of how to route to different pages based on auth state..
In my case ,
User open the app for first time --> Intro --> Login --> Home page
I am trying to see how I can implement something below in GetMatielApp()
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:phone_auth_example/homePage.dart';
import 'signUpPage.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: StreamBuilder(
stream: FirebaseAuth.instance.onAuthStateChanged,
builder: (ctx, userSnapshot) {
if (userSnapshot.hasData) {
return HomePage();
} else if (userSnapshot.hasError) {
return CircularProgressIndicator();
}
return LoginPage();
},
));
}
}
I am using Get CLI and the default is like below..I need to control the routing based on authentication state within the getPages... getPages: AppPages.routes,
Widget build(BuildContext context) {
return GetMaterialApp(
title: "MyApp",
initialRoute: AppPages.INITIAL,
getPages: AppPages.routes,
theme: lightThemeData(context),
);
}
Beta Was this translation helpful? Give feedback.
All reactions