toggleRepeat method

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

Toggles repeat on the current player.

Implementation

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

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