createSearchResultFromMap function
Implementation
SearchResult createSearchResultFromMap(Map<String, dynamic> map) {
switch (map['type']) {
case 'SONG':
return SongDetailedSearchResult(
songDetailed: SongDetailed.fromMap(map),
);
case 'VIDEO':
return VideoDetailedSearchResult(
videoDetailed: VideoDetailed.fromMap(map),
);
case 'ALBUM':
return AlbumDetailedSearchResult(
albumDetailed: AlbumDetailed.fromMap(map),
);
case 'ARTIST':
return ArtistDetailedSearchResult(
artistDetailed: ArtistDetailed.fromMap(map),
);
case 'PLAYLIST':
return PlaylistDetailedSearchResult(
playlistDetailed: PlaylistDetailed.fromMap(map),
);
default:
throw ArgumentError('Tipo inválido para SearchResult: ${map['type']}');
}
}