reorder method
Reorders items in a playlist with playlistId
and its
optional snapshotId
against which you want to make the changes.
rangeStart
is the position of the first item to be reordered.
insertBefore
is the position where the item(s) should be inserted.
To reorder the item(s) to the end of the playlist, simply set insertBefore
to the position after the last item.
rangeLength
is the amount of items to be reordered. Defaults to 1
if not set.
The range of items to be reordered begins from the rangeStart
position,
and includes the rangeLength
subsequent items.
If snapshotId
is null
, the current id is used.
Returns a new snapshotId
for the playlist.
Implementation
Future<String> reorder(String playlistId,
{required int rangeStart,
required int insertBefore,
int rangeLength = 1,
String? snapshotId}) async {
assert(rangeStart >= 0, 'rangeStart out of bounds');
var body = <String, dynamic>{
'range_start': rangeStart,
'insert_before': insertBefore,
'range_length': rangeLength,
};
if (snapshotId != null) {
body['snapshot_id'] = snapshotId;
}
return _reorderOrReplace(playlistId, jsonEncode(body));
}