toggleShuffle method

Future toggleShuffle({
  1. bool? state,
})

Toggles shuffle on the current player.

Implementation

Future toggleShuffle({bool? state}) async {
  if (_currentPlayer?.deviceID == null) {
    throw PlatformException(
        message: 'Spotify player not connected!', code: 'Playback Error');
  }

  await _dio.put(
    '/shuffle',
    queryParameters: {'state': state, 'device_id': _currentPlayer!.deviceID},
    options: Options(
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer ${await _getSpotifyAuthToken()}'
      },
    ),
  );
}