/ 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

Ban and unban a user

Copy link

Operators of an open or group channel can remove any users that behave inappropriately in the channel using the ban feature. A banned user is immediately kicked out of the channel, but allowed to participate in the channel again after the time specified in the seconds property has passed. Operators can ban and unban users using the following code.

Open channel

Copy link
try {
    final channel = await OpenChannel.getChannel(CHANNEL_URL);
    // Ban a user.
    await channel.banUser(USER_ID, seconds: SECONDS);
    // The user is successfully banned from the channel.
    // You can display a message to let the user know they have been banned.

    // Unban a user.
    await channel.unbanUser(USER_ID);
    // The user is successfully unbanned from the channel.
    // You can display a message to let the user know they have been unbanned.
} catch (e) {
    // Handle error.
}

Group channel

Copy link
try {
    await groupChannel.banUser(
        userId: USER_ID,
        seconds: SECONDS,
        description: DESCRIPTION
    );
    // The user is successfully banned from the channel.
    // You can display a message to let the user know they have been banned.

    await groupChannel.unbanUser(userId: USER_ID);
    // The user is successfully unbanned.
    // You can display a message to let the user know they have been unbanned.
} catch (e) {
    // Handle error.
}