Chat / Flutter
Current version: v3
Chat Flutter v3
Chat Flutter
Chat
Flutter
Home
/
Chat
/
Flutter
/
User

Mute and unmute a user

Operators of an open or group channel can restrict selected users from sending messages to the channel using the mute feature. A muted user remains in the channel and is allowed to view the messages but they can't send any messages to the channel until the operators unmute them. Operators can mute and unmute users using the following code.

Open channel

try {
    final channel = await OpenChannel.getChannel(CHANNEL_URL);
    // Mute a user.
    await channel.muteUser(USER_ID, seconds: SECONDS);
    // The user is successfully muted from the channel.
    // You can notify the user of being muted by displaying a prompt.

    // Unmute a user.
    await channel.unmuteUser(USER_ID);
    // The user is successfully unmuted from the channel.
    // You can notify the user of being unmuted by displaying a prompt.
} catch (e) {
    // Handle error.
}

Group channel

try {
    await groupChannel.muteUser(
        userId: USER_ID,
        seconds: SECONDS,
        description: DESCRIPTION
    );
    // The user is successfully muted.
    // You could notify the user of being muted by displaying a prompt.

    await groupChannel.unmuteUser(userId: USER_ID);
    // The user is successfully unmuted.
    // You could notify the user of being unmuted by displaying a prompt.
} catch (e) {
    // Handle error.
}