Hi guys, I copied my tutorial from the old FF-Community and now I'm posting it here, Because it was helpful for many users. ๐ Have fun!
This is a tutorial to build a block user function. A registered user can block another user and hide the profile and all posts of the blocked user. And there is a "Unblock List" to unblock the Blocked Users. This function is important if you want to build a social app and is also prescribed in the Apple guidelines, when you want to publish your App in the Stores! ๐ฑ
Okay, but said too much now. Let us begin! ๐
1. First create a new List in the Collection "Users".
2. Add a Custom Function.
Code:ย
import 'dart:math' as math;
bool ifUserinBlockedList(
List<DocumentReference> userblocked,
DocumentReference user,
DocumentReference authUser,
) {
if (user == authUser) {
return true;
} else {
if (userblocked.contains(user)) {
return false;
} else {
return true;
}
}
}
4. Add a Backen Call Action to add the User to the Block-List
Add Visibility
5. Add Visibility for hiding the User Post, if the User is blocked.
Blocked users List to unblock users:
6. Generate Children from Variable
7. Add a Query Type to your Row
8. Add a Backen Call to unblock User
Now you can add the variables like: username, picture, ....
I hope that helped. ๐ I'm very bad at tutorial making. If you have any questions, I'll be happy to answer them. Just write it in the comments! Happy Building! ๐