Home > Software engineering >  how its work i am trying user uid in firebaseanimated list
how its work i am trying user uid in firebaseanimated list

Time:09-01

@override
  User? user = FirebaseAuth.instance.currentUser;
  Query dbRef =FirebaseDatabase.instance.ref().child('user').child(widget.user!.uid);
  Widget listItem({required Map student})  {
    // TODO: implement build
    throw UnimplementedError();
  }

enter image description here

error The instance member 'widget' can't be accessed in an initializer.

CodePudding user response:

Here is my take on your question:

Replace widget.user!.uid with user!.uid

Your code will look something like this.

@override
  Widget listItem({required Map student})  {
    User? user = FirebaseAuth.instance.currentUser;
    Query dbRef =FirebaseDatabase.instance.ref().child('user').child(user!.uid);
    // TODO: implement build
    throw UnimplementedError();
  }

Check for the value of user to ensure it is not null.

  • Related