diff --git a/lib/provider/spotify/lyrics/synced.dart b/lib/provider/spotify/lyrics/synced.dart index 066596a95..afb27a6b2 100644 --- a/lib/provider/spotify/lyrics/synced.dart +++ b/lib/provider/spotify/lyrics/synced.dart @@ -30,7 +30,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier ); } final linesRaw = Map.castFrom( - jsonDecode(res.body), + jsonDecode(utf8.decode(res.bodyBytes)), )["lyrics"]?["lines"] as List?; final lines = linesRaw?.map((line) { @@ -83,7 +83,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier ); } - final json = jsonDecode(res.body) as Map; + final json = jsonDecode(utf8.decode(res.bodyBytes)) as Map; final syncedLyricsRaw = json["syncedLyrics"] as String?; final syncedLyrics = syncedLyricsRaw?.isNotEmpty == true diff --git a/lib/services/custom_spotify_endpoints/spotify_endpoints.dart b/lib/services/custom_spotify_endpoints/spotify_endpoints.dart index d8600366a..553f68245 100644 --- a/lib/services/custom_spotify_endpoints/spotify_endpoints.dart +++ b/lib/services/custom_spotify_endpoints/spotify_endpoints.dart @@ -75,7 +75,7 @@ class CustomSpotifyEndpoints { ); if (res.statusCode == 200) { - return jsonDecode(res.body); + return jsonDecode(utf8.decode(res.bodyBytes)); } else { throw Exception( '[CustomSpotifyEndpoints.getView]: Failed to get view' @@ -96,7 +96,7 @@ class CustomSpotifyEndpoints { ); if (res.statusCode == 200) { - final body = jsonDecode(res.body); + final body = jsonDecode(utf8.decode(res.bodyBytes)); return List.from(body["genres"] ?? []); } else { throw Exception( @@ -160,7 +160,7 @@ class CustomSpotifyEndpoints { "accept": "application/json", }, ); - final result = jsonDecode(res.body); + final result = jsonDecode(utf8.decode(res.bodyBytes)); return List.castFrom( result["tracks"].map((track) => Track.fromJson(track)).toList(), ); @@ -175,7 +175,7 @@ class CustomSpotifyEndpoints { "accept": "application/json", }, ); - return SpotifyFriends.fromJson(jsonDecode(res.body)); + return SpotifyFriends.fromJson(jsonDecode(utf8.decode(res.bodyBytes))); } Future getHomeFeed({ @@ -232,7 +232,7 @@ class CustomSpotifyEndpoints { final data = SpotifyHomeFeed.fromJson( transformHomeFeedJsonMap( - jsonDecode(response.body), + jsonDecode(utf8.decode(response.bodyBytes)), ), ); @@ -293,7 +293,8 @@ class CustomSpotifyEndpoints { final data = SpotifyHomeFeedSection.fromJson( transformSectionItemJsonMap( - jsonDecode(response.body)["data"]["homeSections"]["sections"][0], + jsonDecode(utf8.decode(response.bodyBytes))["data"]["homeSections"] + ["sections"][0], ), ); diff --git a/lib/utils/service_utils.dart b/lib/utils/service_utils.dart index 50e923478..1432eb539 100644 --- a/lib/utils/service_utils.dart +++ b/lib/utils/service_utils.dart @@ -115,7 +115,7 @@ abstract class ServiceUtils { Uri.parse(authHeader ? reqUrl : "$reqUrl&access_token=$apiKey"), headers: authHeader ? headers : null, ); - Map data = jsonDecode(response.body)["response"]; + Map data = jsonDecode(utf8.decode(response.bodyBytes))["response"]; if (data["hits"]?.length == 0) return null; List results = data["hits"]?.map((val) { return {