Skip to content

Commit

Permalink
fix: some text are garbled in different parts of the app #1463 #1505
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Jun 1, 2024
1 parent 82307bc commit d2683c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/provider/spotify/lyrics/synced.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier<SubtitleSimple, Track?>
);
}
final linesRaw = Map.castFrom<dynamic, dynamic, String, dynamic>(
jsonDecode(res.body),
jsonDecode(utf8.decode(res.bodyBytes)),
)["lyrics"]?["lines"] as List?;

final lines = linesRaw?.map((line) {
Expand Down Expand Up @@ -83,7 +83,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier<SubtitleSimple, Track?>
);
}

final json = jsonDecode(res.body) as Map<String, dynamic>;
final json = jsonDecode(utf8.decode(res.bodyBytes)) as Map<String, dynamic>;

final syncedLyricsRaw = json["syncedLyrics"] as String?;
final syncedLyrics = syncedLyricsRaw?.isNotEmpty == true
Expand Down
13 changes: 7 additions & 6 deletions lib/services/custom_spotify_endpoints/spotify_endpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -96,7 +96,7 @@ class CustomSpotifyEndpoints {
);

if (res.statusCode == 200) {
final body = jsonDecode(res.body);
final body = jsonDecode(utf8.decode(res.bodyBytes));
return List<String>.from(body["genres"] ?? []);
} else {
throw Exception(
Expand Down Expand Up @@ -160,7 +160,7 @@ class CustomSpotifyEndpoints {
"accept": "application/json",
},
);
final result = jsonDecode(res.body);
final result = jsonDecode(utf8.decode(res.bodyBytes));
return List.castFrom<dynamic, Track>(
result["tracks"].map((track) => Track.fromJson(track)).toList(),
);
Expand All @@ -175,7 +175,7 @@ class CustomSpotifyEndpoints {
"accept": "application/json",
},
);
return SpotifyFriends.fromJson(jsonDecode(res.body));
return SpotifyFriends.fromJson(jsonDecode(utf8.decode(res.bodyBytes)));
}

Future<SpotifyHomeFeed> getHomeFeed({
Expand Down Expand Up @@ -232,7 +232,7 @@ class CustomSpotifyEndpoints {

final data = SpotifyHomeFeed.fromJson(
transformHomeFeedJsonMap(
jsonDecode(response.body),
jsonDecode(utf8.decode(response.bodyBytes)),
),
);

Expand Down Expand Up @@ -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],
),
);

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/service_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 <String, dynamic>{
Expand Down

0 comments on commit d2683c5

Please sign in to comment.