Open vovaklh opened 1 year ago
In the search, the access of the popularity
property can only be done throughArtist
and Track
. It is not possible with Album
as the search uses a simple version (AlbumSimple
) of the Album
model, which does not contain the popularity
property. I think an investigation is necessary here, if Album
can bu used in the search handling.
What would also be interesting is to extract common properties like href
of popularity
into parent objects, so that sorting by popularity beyond the search result type (Album
, Track
etc.) can be possible. @rinukkusu What do you think about this?
@vovaklh, I would filter out the Album, Tracks etc. of the search results into a separate lists and sort each type by popularity.
Yeah, we'd need to look into that Album
issue. The Spotify API docs sadly don't really make clear when they're using the stripped down version of their entities and when not. Sometimes you can deduct it from the request/response examples, but they don't seem to be always accurate.
Regarding this issue, I am suggesting this solution:
class Popularity {
int? popularity;
}
so that Artist
and Track
can implement it with
class Track extends TrackSimple implements Popularity {
...
}
, so that it is possible to extract the types with a popularity property by implementing
var search = await spotify.search.get('metallica').first(2);
search.forEach((pages) {
var pops = pages.items!.whereType<Popularity>().toList();
pops.sort((a, b) => a.popularity?.compareTo(b.popularity ?? 0) ?? 0);
...
}
@rinukkusu @vovaklh What do you think?
Now search response contains a List of pages. Each page contains tracks or albums, or something else. How I can combine tracks and albums on UI and sort data by popularity?