Open mfizz1 opened 1 year ago
@mfizz1 Thanks for the report. Can you provide your flutter doctor -v and plugin version you are using that is throwing the reported error ? There was a similar issue fixed earlier this year that you can check and see if it helps in your case or not.
Updated the flutter doctor and plugin is as follows:
firebase_ui_auth:
dependency: "direct main"
description:
name: firebase_ui_auth
sha256: e439571fcad7ed48450eed8d64c70b93765526b876327055469806a51101eff0
url: "https://pub.dev"
source: hosted
version: "1.6.2"
I have looked at the UserCreated
state, but I am not sure how it would help in this case. The user is waiting for the email to be verified, once user has completed this, they move on to the "profile" page. This example is straight from the the docs. I saw last month, someone else raised this as an issue as well but it was closed without a fix firebase/flutterfire#11052
Thanks for the update. I tried with the plugin example running on latest master version, registered new user, received email, verified but when clicked continue, I got dynamic link error, but while waiting to confirm, I didn't the reported error:
Are there any exact steps or if you could provide a short video when the error triggers would be good to make this issue actionable.
I suppose the question is, what is the expected behaviour here? Once the user verifies email, should it automatically proceed to the next screen? Or does the user have to sign in again or change resume state?
When you verified email, what happened on screen?
I will try producing the error locally.
Hi @mfizz1, have you been able to reproduce this locally? I used the plugin example app to do a registration and I was able to register without any issues.
As to what is supposed to happen when you verify your email, it depends on how you've setup your Auth States but with the plugin example app, you will be redirected to the profile page (and based on what I see in your code sample, the same thing should happen)
This is where it seems to be an issue. Whilst I am able to replicate the issue, in terms of the behaviour, it's not flagging up any issues.
The only way I am able to proceed to the screen after email verification, is to cycle to another app and back into this one. Which triggers something to go to profile page. Otherwise I'm waiting with the circular progress indicator.
I will try again today.
I still haven't managed to produce the null error locally. But I noticed noticed a lot more things. Something to do with resuming from a paused state / cycling back the app. One of the other errors produced was:
ββββββββ Exception caught by foundation library ββββββββββββββββββββββββββββββββ
The following assertion was thrown while dispatching notifications for EmailVerificationController:
setState() called after dispose(): __EmailVerificationScreenContentState#a7daf(lifecycle state: defunct, not mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
When the exception was thrown, this was the stack
#0 State.setState.<anonymous closure>
firebase/flutterfire#1 State.setState
firebase/flutterfire#2 __EmailVerificationScreenContentState._sendEmailVerification.<anonymous closure>
firebase/flutterfire#3 ChangeNotifier.notifyListeners
firebase/flutterfire#4 ValueNotifier.value=
firebase/flutterfire#5 EmailVerificationController.reload
<asynchronous suspension>
The EmailVerificationController sending notification was: EmailVerificationController#72e1b(EmailVerificationState.verified)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
I am sure it must be related as the user cycles back to and from the app when switching to email client
@mfizz1 I tried again, this time, using the email client and app from same device and switched back and forth while email was being verified, but didn't get the above reported and originally reported error. Upon email verification, the user is taken to profile page as below:
Based on the error report, I am going ahead and labeling for team's attention and input.
/cc @lesnitsky
One thing that definitely isn't happening for me is the automatically proceeding to the next screen until the user cycles the app or signs out or signs in again.
I have had several users reporting the same issue.
I am facing the exact issue. After a user registers, they are taken to the Email Verification Screen. The loader runs to instruct the user to click on the link in the verification email. The user does click the link, but no event is fired in the app, and the user never moves past that verification screen until manually signing out and signing in. My StreamBuilder code is as follows:
StreamBuilder<User?>(
stream: _auth.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
// Loading indicator or splash screen while checking authentication status.
return const CircularProgressIndicator();
}
final user = snapshot.data;
if (user == null) {
// User is not signed in, show the SignInScreen().
return SignInScreen(
providers: [EmailAuthProvider()],
);
} else {
if (!user.emailVerified) {
// User is signed in but email is not verified, show EmailVerificationScreen().
return EmailVerificationScreen(auth: _auth);
} else {
// User is signed in and email is verified, show ProfileScreen().
return const ProfileScreen();
}
}
},
),
where final FirebaseAuth _auth = FirebaseAuth.instance;
I am facing the exact issue. After a user registers, they are taken to the Email Verification Screen. The loader runs to instruct the user to click on the link in the verification email. The user does click the link, but no event is fired in the app, and the user never moves past that verification screen until manually signing out and signing in. My StreamBuilder code is as follows:
StreamBuilder<User?>( stream: _auth.authStateChanges(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { // Loading indicator or splash screen while checking authentication status. return const CircularProgressIndicator(); } final user = snapshot.data; if (user == null) { // User is not signed in, show the SignInScreen(). return SignInScreen( providers: [EmailAuthProvider()], ); } else { if (!user.emailVerified) { // User is signed in but email is not verified, show EmailVerificationScreen(). return EmailVerificationScreen(auth: _auth); } else { // User is signed in and email is verified, show ProfileScreen(). return const ProfileScreen(); } } }, ),
where
final FirebaseAuth _auth = FirebaseAuth.instance;
Hey!
Have you got the solution... I am facing the same problem?
Hi! Facing the same problem recently. 2 users. one user re-installed the app to get it to work. any feedback on this would be great!
from Crashlytics: Null check operator used on a null value email_verification.dart - Line 68 EmailVerificationController.user + 68
Bug report
Describe the bug Getting a null check operator error when user registers for the first time and is then sent to email verification screen, waiting to verify their email. When the error occurs I get a varied response from the UI sometimes a blank screen, pressing back brings them back to login screen.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
Continue waiting for user to verify email
Sample project
This is what I use for my registration screen:
Additional context
Error Details:
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` [β] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.22621.1992], locale en-GB) β’ Flutter version 3.10.6 on channel stable at C:\Development\flutter β’ Upstream repository https://github.com/flutter/flutter.git β’ Framework revision f468f3366c (3 weeks ago), 2023-07-12 15:19:05 -0700 β’ Engine revision cdbeda788a β’ Dart version 3.0.6 β’ DevTools version 2.23.1 [β] Windows Version (Installed version of Windows is version 10 or higher) [β] Android toolchain - develop for Android devices (Android SDK version 33.0.2) β’ Android SDK at C:\Development β’ Platform android-33, build-tools 33.0.2 β’ ANDROID_HOME = C:\Development β’ ANDROID_SDK_ROOT = C:\Development\tools β’ Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java β’ Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694) β’ All Android licenses accepted. [β] Chrome - develop for the web β’ Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [β] Android Studio (version 2022.2) β’ Android Studio at C:\Program Files\Android\Android Studio β’ Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter β’ Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart β’ Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694) [β] VS Code (version 1.80.0) β’ VS Code at ~\AppData\Local\Programs\Microsoft VS Code β’ Flutter extension version 3.68.0 [β] Connected device (3 available) β’ VOG L09 (mobile) β’ 192.168.1.165:5555 β’ android-arm64 β’ Android 10 (API 29) β’ Chrome (web) β’ chrome β’ web-javascript β’ Google Chrome 115.0.5790.110 β’ Edge (web) β’ edge β’ web-javascript β’ Microsoft Edge 115.0.1901.188 [β] Network resources β’ All expected network resources are available. β’ No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` PASTE OUTPUT INSIDE HERE ```