/// Mirrors internal/api/types.go HomeIndexPayload. Five flat slices of /// entity ID strings — the per-item rendering variant of HomeData. /// Section name implies entity type; no per-entry type tag is needed. /// /// Slices are non-null after fromJson so callers can branch on `length` /// instead of dealing with null sections. class HomeIndex { const HomeIndex({ required this.recentlyAddedAlbums, required this.rediscoverAlbums, required this.rediscoverArtists, required this.mostPlayedTracks, required this.lastPlayedArtists, }); final List recentlyAddedAlbums; final List rediscoverAlbums; final List rediscoverArtists; final List mostPlayedTracks; final List lastPlayedArtists; static const empty = HomeIndex( recentlyAddedAlbums: [], rediscoverAlbums: [], rediscoverArtists: [], mostPlayedTracks: [], lastPlayedArtists: [], ); factory HomeIndex.fromJson(Map j) { List ids(String key) => ((j[key] as List?) ?? const []).map((e) => e.toString()).toList(); return HomeIndex( recentlyAddedAlbums: ids('recently_added_albums'), rediscoverAlbums: ids('rediscover_albums'), rediscoverArtists: ids('rediscover_artists'), mostPlayedTracks: ids('most_played_tracks'), lastPlayedArtists: ids('last_played_artists'), ); } }