Enable users to block and unblock other users in your Flutter chat app using CometChat’sDocumentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
blockUsers and unblockUsers methods.
Overview
The Block User feature lets one user prevent another from sending messages or interacting with them. Essential for user privacy, spam control, and moderation.Prerequisites
- A Flutter project with CometChat UIKit Flutter V6 installed
- Initialized CometChat credentials (
appID,region,authKey)
Components
| Component | Role |
|---|---|
CometChatUIKit.blockUsers([...]) | SDK method to block specified user(s) |
CometChatUIKit.unblockUsers([...]) | SDK method to unblock specified user(s) |
ElevatedButton | Flutter widget for block/unblock actions |
Integration Steps
Add “Block User” Button
- Dart
Add “Unblock User” Button
- Dart
Customization Options
- Conditional Rendering: Display “Block” or “Unblock” based on
user.blockedByMestate - Modal Confirmation: Wrap actions in
showDialogfor confirmation prompts - Self-Block Prevention: Disable the button if
user.uid == loggedInUser.uid
Summary
| Feature | Method |
|---|---|
| Block User | CometChatUIKit.blockUsers([...]) |
| Unblock User | CometChatUIKit.unblockUsers([...]) |