/ 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

Retrieve a list of channels

Copy link

You can retrieve a list of open channels using OpenChannelListQuery's loadNext() method, which returns a list of OpenChannel objects.

You can also retrieve a list of the current user's private group channels using the loadNext() method of a GroupChannelListQuery instance, which returns a list of GroupChannel objects. Using the includeEmptyChannel property of a GroupChannelListQuery instance, you can determine whether to include empty channels in the result. Empty channels are group channels that have been created but don't contain any messages, and thus aren't included in the result by default. However, if you turn off the Chat history option on Sendbird Dashboard, you may retrieve empty channels in the result.

Note: See search group channels by name, URL, or other filters to find out how to search for specific group channels using keywords and filters.


Open channel

Copy link

Create an OpenChannelListQuery instance to retrieve a list of open channels matching the specifications set by OpenChannelListQuery. After a list of open channels is successfully retrieved, you can access the data of each open channel from the result list through the openChannel parameter of the callback method.

try {
    final listQuery = OpenChannelListQuery()
        ..channelUrl = channel.channelUrl;

    final result = await listQuery.loadNext();
    // A list of open channels is successfully retrieved.
    // Through the openChannel parameter of the callback method, you can access the data
    // of each open channel from the result list that the Sendbird server has passed.
} catch (e) {
    // Handle error.
}

Group channel

Copy link

Create a GroupChannelListQuery instance to retrieve a list of group channels matching the specifications set by GroupChannelListQuery.

You can set GroupChannelListQuery's includeEmptyChannel property to true so that users can view empty channels since the view chat history option is turned off to prevent new members from seeing previous conversations. You can determine whether to turn on the chat history option on Sendbird Dashboard under Settings > Chat > Channels > Group channels.

After a list of group channels is successfully retrieved, you can access the data of each channel from the result list through the groupChannel parameter of the callback method.

try {
    final query = GroupChannelListQuery()
        ..includeEmptyChannel = true
        ..memberStateFilter = MemberStateFilter.joined
        ..order = GroupChannelListOrder.latestLastMessage
        ..limit = 15;
    final result = await query.loadNext();
    // A list of private group channels matching the list query criteria is successfully retrieved.
} catch (e) {
    // Handle error.
}

List of properties

Copy link
Property nameTypeDescription

includeEmptyChannel

bool

Determines whether to include empty group channels in the results.

memberStateFilter

MemberStateFilter

Restricts the search scope based on the state of the current user. Acceptable values are all, joined, and invited.

order

GroupChannelListOrder

A list of user IDs invited to the channel. Acceptable values are chronological, latestLastMessage, channelNameAlphabetical, and metadataValueAlphabetical.

limit

int

Specifies the number of results to return per call. Acceptable values are 1 to 100, inclusive. The recommended value for this parameter is 20.


All public group channels

Copy link

If you want to retrieve a list of all public group channels regardless of the current user's membership status, use the PublicGroupChannelListQuery instance and set PublicGroupChannelMembershipFilter to PublicGroupChannelMembershipFilter.all in PublicGroupChannelListQuery.

After a list of public group channels is successfully retrieved, you can access the data of each channel from the result list.


Supergroup channels

Copy link

To retrieve a list of Supergroup channels, you can set the superChannelFilter property to SuperChannelFilter.superChannel in either the GroupChannelListQuery or PublicGroupChannelListQuery instance. The superChannelFilter property works much like other search filters. Use GroupChannelListQuery when only searching for group channels that the current user belongs to, and use PublicGroupChannelListQuery when searching for all public group channels regardless of the current user's membership status.

When queried channels are returned, you can check if the channel is a Supergroup channel by looking at whether the isSuper property has a value of true.

Using GroupChannelListQuery

Copy link
  final query = GroupChannelListQuery();
  query.superChannelFilter = SuperChannelFilter.superChannel;
  final result = await query.loadNext();

Using PublicGroupChannelListQuery

Copy link
  final query = PublicGroupChannelListQuery();
  query.superChannelFilter = SuperChannelFilter.all;
  final result = await query.loadNext();