getAllFriendList method
Future<List?>
getAllFriendList(
- dynamic friendId,
- dynamic currentUserId
)
Implementation
Future<List<dynamic>?> getAllFriendList(
var friendId, var currentUserId) async {
FirebaseFirestore.instance
.collection(getDocName())
.doc(friendId)
.get()
.then((DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists) {
friendList = documentSnapshot.get('friends');
if (friendList!.contains(currentUserId)) {
} else {
friendList!.add(currentUserId);
FirebaseFirestore.instance
.collection(getDocName())
.doc(friendId)
.update({"friends": friendList}).whenComplete(() => {});
}
return friendList;
} else {
return friendList;
//print('Document does not exist on the database');
}
});
}