/ SDKs / Flutter
Chat SDKs Flutter v4
Chat SDKs Flutter
Chat SDKs
Version 4

Retrieve a list of channels

Copy link

You can retrieve a list of OpenChannel objects using the next() method of an OpenChannelListQuery instance.

On the other hand, a list of GroupChannel objects can be retrieved through GroupChannelCollection and its loadMore() method. First, create a GroupChannelListQuery instance. The GroupChannelListQuery instance returns both public and private group channels that the current user has joined. To retrieve a list of certain group channels such as public group channels or Supergroup channels, use the the list query's filters as described at the bottom of this page.

Note: You can also search for specific open channels and group channels with 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 query = OpenChannelListQuery()
    ..channelUrl = channel.channelUrl;

  final openChannels = await query.next();
  // A list of open channels is successfully retrieved.
} catch (e) {
  // Handle error.

Group channels

Copy link

A group channel list view can be drawn with a GroupChannelCollection instance. First, create a GroupChannelListQuery instance. This determines which channel to include in the channel list and how to list channels in order.

To retrieve group channels in the collection, call hasMore first to check whether there are more channels to load for the collection. If so, call loadMore().

To learn more about how the collection works, see Group channel collection under Local caching.

try {
  // Check whether there are more channels to load before calling loadMore().
  if (collection.hasMore) {
      await collection.loadMore();
} catch (e) {
  // Handle error.

Filter group channels using GroupChannelListQuery

Copy link

When creating a GroupChannelCollection instance, you need to set params within GroupChannelListQuery first. The params in GroupChannelListQuery works much like other search options, retrieving a list of group channels matching the specifications set by properties in the query instance. For example, use myMemberStateFilter when searching for only the group channels that the current user belongs to, and publicChannelFilter when searching for all public group channels regardless of the current user's membership status. To retrieve a list of Supergroup channels, you can set the superChannelFilter property to SuperChannelFilter.superChannelOnly.

Once the params is set, you can use the query instance for query parameter in GroupChannelCollection constructor.

// Create a GroupChannelListQuery instance.
final query = GroupChannelListQuery()
  ..includeEmpty = true // The default value is true.
  ..order = GroupChannelListQueryOrder.chronological // Acceptable values are chronological, latestLastMessage(default), channelNameAlphabetical and metadataValueAlphabetical.
  ..publicChannelFilter = PublicChannelFilter.public // Retrieve public group channels.
  ..superChannelFilter = SuperChannelFilter.superChannelOnly; // Retrieve Supergroup channels.
  // You can add other params setters.


Copy link

This table only contains properties shown in the code above. To see the comprehensive list of all available methods and properties, see GroupChannelListQuery in API reference.

Property nameTypeDescription



Determines whether the list includes empty group channels that don't show any messages sent before the current user joins it because the chat history option is turned off. You can turn on or off the chat history option under Settings > Chat > Channels > Group channels on Sendbird Dashboard.



Determines how to order the channels. Acceptable values are chronological, latestLastMessage, channelNameAlphabetical, and metadataValueAlphabetical. metadataValueAlphabetical works in conjunction with metaDataOrderKeyFilter. (Default: latestLastMessage)



Determines which group channels to include in the list based on their isPublic value. Acceptable values are private, public, and all. (Default: all)



Determines which group channels to include in the list based on their isSuper value. Acceptable values are nonsuperChannelOnly, superChannelOnly, and all. (Default: all)