@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();
}
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.