FirebaseUser no longer exists in firebase_auth
Undefined class 'FirebaseUser'.Short answer
FirebaseUser was renamed User in firebase_auth 0.18. AuthResult became UserCredential, currentUser() became a plain getter, and onAuthStateChanged became authStateChanges(). Replace each name, import package:firebase_auth/firebase_auth.dart, and read the signed-in user from credential.user.
Fix it fast
1Find out which cause you have
List every old name left in the project, so you can replace all of them in one pass.
grep -rn "FirebaseUser\|AuthResult\|onAuthStateChanged\|currentUser()" lib/2Match what you see, then jump to its fix
- 1
Undefined class 'FirebaseUser' on a field, parameter or return typeThe class was renamed from FirebaseUser to UserFix - 2
Undefined class 'AuthResult', or 'user' used on a result of the wrong typeSign-in methods return UserCredential, not AuthResultFix - 3
Code still calls currentUser() as a method, or still uses onAuthStateChangedcurrentUser() and onAuthStateChanged were replacedFix
- 1
What does the error look like?
Undefined class 'FirebaseUser'.Undefined class 'AuthResult'.
Cause 1 of 3
The class was renamed from FirebaseUser to User
1Check
The firebase_auth changelog for 0.18.0 lists the rename as a breaking change. Code written for older releases still uses the old name.
grep -rn "FirebaseUser" lib/2Fix
Rename the type to User and make sure the package is imported. Hide the name if it clashes with your own User class.
import 'package:firebase_auth/firebase_auth.dart';
User? _user = FirebaseAuth.instance.currentUser;3Verify
dart analyze no longer reports the undefined class.
dart analyzeConfirmed by raw.githubusercontent.com
Cause 2 of 3
Sign-in methods return UserCredential, not AuthResult
1Check
Since 0.18.0, AuthResult is called UserCredential, and the signed-in user is its user property.
grep -rn "AuthResult" lib/2Fix
Change the type, and read the user from the credential.
final UserCredential credential = await FirebaseAuth.instance
.signInWithEmailAndPassword(email: email, password: password);
final User? user = credential.user;3Verify
The file analyzes without errors.
dart analyze lib/Confirmed by raw.githubusercontent.com
Cause 3 of 3
currentUser() and onAuthStateChanged were replaced
1Check
The same release made currentUser a synchronous getter, and deprecated onAuthStateChanged in favour of authStateChanges().
grep -rn "onAuthStateChanged\|currentUser()" lib/2Fix
Use the getter without parentheses and listen to the new stream.
final User? current = FirebaseAuth.instance.currentUser;
FirebaseAuth.instance.authStateChanges().listen((User? user) {
// null means signed out
});3Verify
Run the app, sign in and out, and watch the stream fire.
flutter runConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Read the package changelog before a major firebase_auth upgrade.
- Run dart analyze in CI so a rename shows up as a failed check, not a runtime surprise.
- Keep old tutorials for reference only and check their API names against the current docs.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Mobile apps
firebase_options.dart does not exist in a Flutter project
Undefined name 'DefaultFirebaseOptions'.
firebase_options.dart is not part of a normal Flutter project.
3 causes, each with a fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
AudioCache has no play method after updating audioplayers
The method 'play' isn't defined for the type 'AudioCache'.
Since audioplayers 1.0, AudioCache only turns asset files into local files and caches them.
2 causes, each with a fixMobile apps
Flutter Bloc throws that emit was called after the event handler completed
emit was called after an event handler completed normally.
Each on<Event> handler gets its own Emitter, and it stops working the moment the handler's returned Future completes.
2 causes, each with a fixMobile apps
analysis_options.yaml: the URI it includes can't be found
include_file_not_found
The analyzer reports include_file_not_found when the file named after include: in analysis_options.yaml does not resolve.
2 causes, each with a fixMobile apps
Dart error: the body might complete normally and return null for a non-nullable type
body_might_complete_normally
Dart found a path through your function or callback that reaches the closing brace without a return.
3 causes, each with a fix