I have a Flutter app where I let users sign up with only their email address. It should of course be verified. When sending the request the mail arrives and the link works. It even says "Your email has been verified". For some reason the user in the app is still not registered as verified though.
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: AuthService().userStream,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const LoadingScreen();
}
if (snapshot.hasError) {
return const Scaffold(
body: Padding(
padding: EdgeInsets.all(10),
child: ErrorScreen(),
),
);
} else if (snapshot.hasData) {
if (snapshot.data!.emailVerified) {
return const OverviewScreen();
}
return Scaffold(
body: Center(
child: Column(
children: [
const Spacer(),
const Spacer(),
const Text('Verify yourself'),
const Spacer(),
ElevatedButton(
onPressed: () {
AuthService().user!.sendEmailVerification();
},
child: const Text('Resend verification email'),
),
const Spacer(),
],
)),
);
} else {
return const RegisterScreen();
}
},
);
}
}
AuthService().userStream is just
FirebaseAuth.instance.authStateChanges();
And AuthService().user is just
FirebaseAuth.instance.currentUser;
This question here tackles a similar problem, but even after restarting the app, the user's still not verified. Using the StreamBuilder should prevent manual reloading anyway.