The getter 'onAuthStateChanged' isn't defined for the type 'FirebaseAuth'. Try importing the library that defines 'onAuthStateChanged', correcting the name to the name of an existing getter, or defining a getter or field named 'onAuthStateChanged' thanks code is here below..
import 'package:brew_crew/model/user.dart';
import 'package:firebase_auth/firebase_auth.dart';
class AuthService{
final FirebaseAuth _auth = FirebaseAuth.instance;
// Create user object based on FirebaseUser
CurrentUser? _customModelForFirebaseUser(User user) {
return user != null ? CurrentUser (uid: user.uid) : null;
}
// auth changed user stream
Stream<CurrentUser > get user {
return _auth.onAuthStateChanged // here is the problem
.map(_customModelForFirebaseUser);
}
//sin in anon
Future signInAnon() async{
try {
UserCredential result = await _auth.signInAnonymously();
User? user = result.user;
return _customModelForFirebaseUser(user!);
}catch (e) {
print(e.toString());
return null;
}
}
//sign in with E-mail and password
//Register with E-mail and passqord
//Sign out
}