userChanges stream in Flutter Fire does not stream profile changes

Viewed 432

According to FlutterFire docs, userChanges should stream any changes to user profile in Firebase. I added the following code to a screen:

class UserInfo extends StatefulWidget {
  UserInfo({Key key}) : super(key: key);

  @override
  _UserInfoState createState() => _UserInfoState();
}

class _UserInfoState extends State<UserInfo> {
  FirebaseUser _user;
  StreamSubscriber _userChnages;

  @override
  void initState() { 
    super.initState();
    _userChanges = FirebaseAuth.instance.userChanges().listen((user) {
      setState(() {
        _user = user;
      })
    })
  }


  @override
  Widget build(BuildContext context) {
    return Container(
       child: Text(_user?.email ?? "No user"),
    );
  }
}

When I make changes outside the app (for example new user verifies email address or I change their displayName in backend) the stream never fetches those changes and the callback of .listen() is never run.

1 Answers
userChanges() notify these cases;
  1. Login
  2. Logout

Any properties that you save on Firestore or Real-time Database (like fullName) does not appear and reaching on FirebaseAuth service.

You can listen firestore or rtdb document for listen user document changes.

You can listen userChanges for login logout

Related