Home > Net >  onPressed not working with database query
onPressed not working with database query

Time:10-11

I have this code:

IconButton(
   onPressed: () {
       acceptFriendRequest;
   },
   icon: const Icon(Icons.check,color: Colors.green,)),

void acceptFriendRequest() async{
   addMutualFriends(sender: widget.friendReq.userID, receiver: current.userID);}

static addMutualFriends({required sender, required receiver}) {
friendsRef
    .doc(sender)
    .collection('pending')
    .doc(receiver)
    .delete();
friendsRef
        .doc(sender)
        .collection('mutual')
        .doc(receiver)
        .set(HashMap<String, Object>());
}

but acceptFriendRequest does nothing. It seems like the method is called but doesn't do anything. Why? Thank you for the answers

CodePudding user response:

It turned out it was the most stupid error. I simply had to use acceptFriendRequest() instead of acceptFriendRequest, probably because it was calling a static method

CodePudding user response:

Do like this: onPressed: acceptFriendRequest,

  • Related