Reputation: 7158
I use flutter plugin firebase_auth: ^0.18.4+1
I get this warning in editor:
The function expression type 'String Function(FirebaseUser)' isn't of type 'String Function(User)'. This means its parameter or return type doesn't match what is expected. Consider changing parameter type(s) or the returned type(s).
FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
Stream<String> get onAuthStateChanged =>
_firebaseAuth.onAuthStateChanged.map((FirebaseUser user) => user?.uid);
Also the 'onAuthStateChanged' is deprecated. How to change it to get stream on onAuthStateChanged?
Upvotes: 0
Views: 1076
Reputation: 80914
Change this:
FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
Stream<String> get onAuthStateChanged =>
_firebaseAuth.onAuthStateChanged.map((FirebaseUser user) => user?.uid);
into this:
FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
Stream<String> get onAuthStateChanged =>
_firebaseAuth.authStateChanges().map((User user) => user?.uid);
You need to use User
class instead of FirebaseUser
.
Upvotes: 2