destroyFavorite method

Future<Tweet> destroyFavorite({
  1. required String id,
  2. bool? includeEntities,
  3. bool? includeExtEditControl,
  4. String tweetMode = 'extended',
  5. TransformResponse<Tweet> transform = defaultTweetTransform,
})

Unfavorites (un-likes) the Tweet specified in the ID parameter as the authenticating user. Returns the un-liked Tweet when successful.

The process invoked by this method is asynchronous. The immediately returned Tweet object may not indicate the resultant favorited status of the Tweet. A 200 OK response from this method will indicate whether the intended action was successful or not.

id: The numerical ID of the Tweet to un-like.

includeEntities: The entities node will not be included when set to false.

includeExtEditControl: The includeExtEditControl node will not be included when set to false. See https://developer.twitter.com/en/docs/twitter-api/v1/edit-tweets

tweetMode: When set to extended, uses the extended Tweets. See https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/intro-to-tweet-json#extendedtweet.

transform: Can be used to parse the request. By default, the response is parsed in an isolate.

See https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-destroy.

Implementation

Future<Tweet> destroyFavorite({
  required String id,
  bool? includeEntities,
  bool? includeExtEditControl,
  String tweetMode = 'extended',
  TransformResponse<Tweet> transform = defaultTweetTransform,
}) async {
  final body = <String, String>{}
    ..addParameter('id', id)
    ..addParameter('include_entities', includeEntities)
    ..addParameter('include_ext_edit_control', includeExtEditControl)
    ..addParameter('tweet_mode', tweetMode);

  return client
      .post(
        Uri.https('api.twitter.com', '1.1/favorites/destroy.json'),
        body: body,
      )
      .then(transform);
}