updatePlaylist method

Future<void> updatePlaylist(
  1. String playlistId,
  2. String playlistName, {
  3. bool? public,
  4. bool? collaborative,
  5. String? description,
})

playlistId - the ID of the playlist to update

playlistName - the new name of the playlist

public - Defaults to true. If true the playlist will be public, if false it will be private.

collaborative - Defaults to false. If true the playlist will be collaborative.

description - the new description of the playlist

Implementation

Future<void> updatePlaylist(
  String playlistId,
  String playlistName, {
  bool? public,
  bool? collaborative,
  String? description,
}) async {
  final url = 'v1/playlists/$playlistId';
  final json = <String, dynamic>{'name': playlistName};

  if (public != null) json['public'] = public;
  if (collaborative != null) json['collaborative'] = collaborative;
  if (description != null) json['description'] = description;

  await _api._put(url, jsonEncode(json));
}