updateCustomList method

Future<TraktList> updateCustomList(
  1. String id,
  2. String listId, {
  3. String? name,
  4. String? description,
  5. CustomListPrivacy? privacy,
  6. bool? displayNumbers,
  7. bool? allowComments,
  8. CustomListSort? sortBy,
  9. CustomListSortHow? sortHow,
})

Update a custom list by sending 1 or more parameters.

If you update the list name, the original slug will still be retained so existing references to this list won't break.

id - User slug listId - Trakt ID or Trakt slug name - Name of the list. description - Description for this list. privacy - Possible values: private, friends, or public displayNumbers - Should each item be numbered? allowComments - Are comments allowed? sortBy - Possible values: rank, added, title, released, runtime, popularity, percentage, votes, my_rating, random, watched, collected sortHow - Possible values: asc, desc

🔒 OAuth Required

Implementation

Future<TraktList> updateCustomList(String id, String listId,
    {String? name,
    String? description,
    CustomListPrivacy? privacy,
    bool? displayNumbers,
    bool? allowComments,
    CustomListSort? sortBy,
    CustomListSortHow? sortHow}) async {
  Map<String, dynamic> body = {};

  if (name != null) {
    body["name"] = name;
  }
  if (description != null) {
    body["description"] = description;
  }
  if (privacy != null) {
    body["privacy"] = privacy.value;
  }
  if (displayNumbers ?? false) {
    body["display_numbers"] = displayNumbers;
  }
  if (allowComments ?? false) {
    body["allow_comments"] = allowComments;
  }
  if (sortBy != null) {
    body["sort_by"] = sortBy.value;
  }
  if (sortHow != null) {
    body["sort_how"] = sortHow.value;
  }
  return await _manager._authenticatedPut<TraktList>("users/$id/lists/$listId", body: jsonEncode(body));
}