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

Retrieve a list of users in an application

By using an ApplicationUserListQuery instance, you can retrieve a list of all or certain users in your Sendbird application. The loadNext() method returns a list of User objects which contain information on users within the application.

// Retrieve all users.
final listQuery = ApplicationUserListQuery();

try {
    final users = await listQuery.loadNext();
    // A list of users is successfully retrieved.
} catch (e) {
    // Handle error.
}

ApplicationUserListQuery

Using a number of different filters in the ApplicationUserListQuery instance, you can retrieve a list of specific users that match the values set in the filters. Currently, the ApplicationUserListQuery instance supports the following filters.

List of filters

Filter nameTypeDescription

userIds

List?

Specifies the unique IDs of users you want to retrieve. Specifying the userIds option enables this filter.

metaDataKey

String?

Specifies the metadata keys of users you want to retrieve. Specifying the metaDataKey option enables this filter.

metaDataValues

List?

Specifies the metadata values of users you want to retrieve. Specifying the metaDataValues option enables this filter.

Note: We recommend you set the maximum number of user IDs in userIds to 250. If exceeded, your query may receive HTTP 414 error indicating that the submitted request data is longer than the Sendbird server is willing to interpret.

// Retrieve specific users using the userIDs filter.
final listQuery = ApplicationUserListQuery();
listQuery.userIds = ['Harry', 'Jay', 'Jin'];

try {
    final users = await listQuery.loadNext();
    // A list of matching users is successfully retrieved.
} catch (e) {
    // Handle error.
}

// Retrieve specific users using the metaDataKey and metaDataValues filter.
final listQuery = ApplicationUserListQuery();
listQuery.metaDataKey = 'hobby';
listQuery.metaDataValues = ['movie', 'book', 'exercise'];

try {
    final users = await listQuery.loadNext();
    // A list of matching users is successfully retrieved.
} catch (e) {
    // Handle error.
}