membersDestroyAll method

Future<void> membersDestroyAll({
  1. String? ownerScreenName,
  2. String? ownerId,
  3. String? listId,
  4. String? slug,
  5. List<String>? userId,
  6. List<String>? screenName,
})

Removes multiple members from a list, by specifying a comma-separated list of member ids or screen names. The authenticated user must own the list to be able to remove members from it. Note that lists can't have more than 500 members, and you are limited to removing up to 100 members to a list at a time with this method.

Please note that there can be issues with lists that rapidly remove and add memberships. Take care when using these methods such that you are not too rapidly switching between removals and adds on the same list.

ownerScreenName The screen name of the user who owns the list being requested by a slug.

ownerId The user ID of the user who owns the list being requested by a slug.

listId The numerical id of the list.

slug You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the ownerId or ownerScreenName parameters.

userId A list of user IDs, up to 100 are allowed in a single request.

screenName A comma separated list of screen names, up to 100 are allowed in a single request.

See https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy_all.

Implementation

Future<void> membersDestroyAll({
  String? ownerScreenName,
  String? ownerId,
  String? listId,
  String? slug,
  List<String>? userId,
  List<String>? screenName,
}) async {
  final body = <String, String>{}
    ..addParameter('owner_screen_name', ownerScreenName)
    ..addParameter('owner_id', ownerId)
    ..addParameter('list_id', listId)
    ..addParameter('slug', slug)
    ..addParameter('user_id', userId)
    ..addParameter('screen_name', screenName);

  await client.post(
    Uri.https('api.twitter.com', '1.1/lists/members/destroy_all.json'),
    body: body,
  );
}