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>( final linesRaw = Map.castFrom<dynamic, dynamic, String, dynamic>(
jsonDecode(res.body), jsonDecode(utf8.decode(res.bodyBytes)),
)["lyrics"]?["lines"] as List?; )["lyrics"]?["lines"] as List?;
final lines = linesRaw?.map((line) { 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 syncedLyricsRaw = json["syncedLyrics"] as String?;
final syncedLyrics = syncedLyricsRaw?.isNotEmpty == true final syncedLyrics = syncedLyricsRaw?.isNotEmpty == true

View File

@ -75,7 +75,7 @@ class CustomSpotifyEndpoints {
); );
if (res.statusCode == 200) { if (res.statusCode == 200) {
return jsonDecode(res.body); return jsonDecode(utf8.decode(res.bodyBytes));
} else { } else {
throw Exception( throw Exception(
'[CustomSpotifyEndpoints.getView]: Failed to get view' '[CustomSpotifyEndpoints.getView]: Failed to get view'
@ -96,7 +96,7 @@ class CustomSpotifyEndpoints {
); );
if (res.statusCode == 200) { if (res.statusCode == 200) {
final body = jsonDecode(res.body); final body = jsonDecode(utf8.decode(res.bodyBytes));
return List<String>.from(body["genres"] ?? []); return List<String>.from(body["genres"] ?? []);
} else { } else {
throw Exception( throw Exception(
@ -160,7 +160,7 @@ class CustomSpotifyEndpoints {
"accept": "application/json", "accept": "application/json",
}, },
); );
final result = jsonDecode(res.body); final result = jsonDecode(utf8.decode(res.bodyBytes));
return List.castFrom<dynamic, Track>( return List.castFrom<dynamic, Track>(
result["tracks"].map((track) => Track.fromJson(track)).toList(), result["tracks"].map((track) => Track.fromJson(track)).toList(),
); );
@ -175,7 +175,7 @@ class CustomSpotifyEndpoints {
"accept": "application/json", "accept": "application/json",
}, },
); );
return SpotifyFriends.fromJson(jsonDecode(res.body)); return SpotifyFriends.fromJson(jsonDecode(utf8.decode(res.bodyBytes)));
} }
Future<SpotifyHomeFeed> getHomeFeed({ Future<SpotifyHomeFeed> getHomeFeed({
@ -232,7 +232,7 @@ class CustomSpotifyEndpoints {
final data = SpotifyHomeFeed.fromJson( final data = SpotifyHomeFeed.fromJson(
transformHomeFeedJsonMap( transformHomeFeedJsonMap(
jsonDecode(response.body), jsonDecode(utf8.decode(response.bodyBytes)),
), ),
); );
@ -293,7 +293,8 @@ class CustomSpotifyEndpoints {
final data = SpotifyHomeFeedSection.fromJson( final data = SpotifyHomeFeedSection.fromJson(
transformSectionItemJsonMap( 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"), Uri.parse(authHeader ? reqUrl : "$reqUrl&access_token=$apiKey"),
headers: authHeader ? headers : null, 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; if (data["hits"]?.length == 0) return null;
List results = data["hits"]?.map((val) { List results = data["hits"]?.map((val) {
return <String, dynamic>{ return <String, dynamic>{