fix: some text are garbled in different parts of the app #1463 #1505

This commit is contained in:
Kingkor Roy Tirtho 2024-06-01 11:41:35 +06:00
parent 82307bc030
commit d2683c52d8
3 changed files with 10 additions and 9 deletions

View File

@ -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) {
@ -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

View File

@ -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<String>.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<dynamic, Track>(
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<SpotifyHomeFeed> 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],
),
);

View File

@ -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>{