/ SDKs / Flutter
SDKs
Chat SDKs Flutter v3
Chat SDKs Flutter
Chat SDKs
Flutter
Version 3
Sendbird Chat SDK v3 for Flutter is no longer supported as a new version is released. Check out our latest Chat SDK v4

Mute and unmute a user

Copy link

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

Copy link
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

Copy link
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.
}