0

I get the idea of automatically navigating based on if the user has data or not, but what I'm facing a problem with is how to check if the user has verified their email and based on that navigate to the new route.

note: i tried using "FirebaseAuth.instance.currentUser.emailVerified == condition" but it didnt work

class WrapperView extends GetView<WrapperController> {
  const WrapperView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
      stream: FirebaseAuth.instance.authStateChanges(),
      builder: ((BuildContext context, AsyncSnapshot snapshot) {
        if (snapshot.hasData) {
          Get.log('has data');
          return ProfileView();
        } else {
          Get.log('has no data');
          return SplashView();
        }
      }),
    );
  }
}
  • 2
    "it didn't work" Note that email verification happens in another application, so your Flutter app won't immediately be aware of it. Without further code, it may take up to an hour before the app picks it up, as it refreshes the ID token that contains this info hourly. If you want to pick it up sooner than that, you can `reload` the user profile, or force refresh on `getIdToken(true)`. – Frank van Puffelen Apr 08 '22 at 21:23
  • For an example, see: https://stackoverflow.com/a/67044680/209103 – Frank van Puffelen Apr 08 '22 at 21:30

0 Answers0