The getter 'AuthStateChanges' isn't defined for the type 'FirebaseAuth'

Issue

I’m trying to get UserProvider for Firebase Auth but the error says:

The getter ‘AuthStateChanges’ isn’t defined for the type ‘FirebaseAuth’.

and

Undefined name ‘_onStateChanged’.

UserProvider.initialize() : _auth = FirebaseAuth.instance {
_auth.AuthStateChanges.listen(_onStateChanged);}

Solution

https://firebase.flutter.dev/docs/migration

DEPRECATED: onAuthStateChanged has been deprecated in favor of authStateChanges().

Answered By – Igor Gomes

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *