flutter_starter
flutter_starter copied to clipboard
Splash UI
Hi, could you please explain to me how you connected the Splash UI defined as initial route ('/') in GetMaterialApp? I do not understand how you get to login page if you have not defined a "home" parameter in GetMaterialApp.
Cheers, Andrea
app routes are defined here. https://github.com/delay/flutter_starter/blob/b34120adcfdb363699aab40d4561701be2ba5b5c/lib/constants/app_routes.dart
and the initial route is set in main.dart
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
ThemeController.to.getThemeModeFromStore();
return GetBuilder<LanguageController>(
builder: (languageController) => Loading(
child: GetMaterialApp(
translations: Localization(),
locale: languageController.getLocale, // <- Current locale
navigatorObservers: [
// FirebaseAnalyticsObserver(analytics: FirebaseAnalytics()),
],
debugShowCheckedModeBanner: false,
//defaultTransition: Transition.fade,
theme: AppThemes.lightTheme,
darkTheme: AppThemes.darkTheme,
themeMode: ThemeMode.system,
initialRoute: "/",
getPages: AppRoutes.routes,
),
),
);
}
}
Thanks! I am still learning GetX. I noticed the AppRoutes.routes constant and I see '/' is mapped to SplashUI. I just don't see when/how the login page is called from SlashUI (or how a login controller handles that).
I appreciate your help! Cheers
To be honest I am probably not the best person to answer this anymore. I haven't really coded in flutter in a couple of years. I am building stuff with sveltekit and vanilla javascript these days. GetX has a bunch of user tutorials at the bottom of this page. https://pub.dev/packages/get#community-channels
@faviasono I am trying to answer on behalf of @delay as he is busy with other things.
Please go to Lib->Controllers->auth_controller.dart. Check the code after init (i guess). Now you can refer the code and check getX documentation for "Get.off() & Get.offAll()"
Code:
handleAuthChanged(_firebaseUser) async {
//get user data from firestore
if (_firebaseUser?.uid != null) {
firestoreUser.bindStream(streamFirestoreUser());
await isAdmin();
}
if (_firebaseUser == null) {
print('Send to signin');
Get.offAll(SignInUI());
} else {
Get.offAll(HomeUI());
}
}