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

Retrieve a list of users in an application

Copy link

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 query = ApplicationUserListQuery();

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

ApplicationUserListQuery

Copy link

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

Copy link
Filter property nameTypeDescription

userIdsFilter

List<String>?

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

nicknameStartsWithFilter

String?

Specifies the nickname of users you want to retrieve. Specifying the nicknameStartsWithFilter option enables this filter.

metaDataKeyFilter

String?

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

metaDataValuesFilter

List<String>?

Specifies the metadata values of users you want to retrieve. Specifying the metaDataValuesFilter 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 query = ApplicationUserListQuery();
query.userIdsFilter = ['Harry', 'Jay', 'Jin'];

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

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

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