diff --git a/lib/src/endpoints/player.dart b/lib/src/endpoints/player.dart index d290cd4..6c99456 100644 --- a/lib/src/endpoints/player.dart +++ b/lib/src/endpoints/player.dart @@ -103,11 +103,13 @@ class PlayerEndpoint extends _MeEndpointBase { {String? deviceId, StartOrResumeOptions? options, bool retrievePlaybackState = true}) async { - var body = options?.toJson(); - var json = jsonEncode(body ?? ''); + final body = options?.toJson(); + final json = body != null ? jsonEncode(body) : null; await _api._put( - '$_path/play?${_buildQuery({'device_id': deviceId})}', json); + '$_path/play?${_buildQuery({'device_id': deviceId})}', + json, + ); return retrievePlaybackState ? playbackState() : null; } diff --git a/lib/src/spotify_base.dart b/lib/src/spotify_base.dart index 2f8a26c..cee0db8 100644 --- a/lib/src/spotify_base.dart +++ b/lib/src/spotify_base.dart @@ -193,7 +193,7 @@ abstract class SpotifyApiBase { return _deleteImpl('$_baseUrl/$path', const {}, body); } - Future _put(String path, [String body = '']) { + Future _put(String path, [String? body]) { return _putImpl('$_baseUrl/$path', const {}, body); }