Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splash UI #29

Open
faviasono opened this issue Apr 13, 2023 · 4 comments
Open

Splash UI #29

faviasono opened this issue Apr 13, 2023 · 4 comments

Comments

@faviasono
Copy link

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

@delay
Copy link
Owner

delay commented Apr 13, 2023

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,
        ),
      ),
    );
  }
}

@faviasono
Copy link
Author

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

@delay
Copy link
Owner

delay commented Apr 13, 2023

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

@salscoding
Copy link

@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());
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants