getSimilar method
Get all the artists similar to this artist.
Implementation
Future<List<Artist>?> getSimilar({
String? artist,
String? mbid,
int? limit,
bool autoCorrect = false,
}) async {
if (artist == null && mbid == null) {
return Future.error(
ScrobblenautException(
description: 'This method requires at least artist or mbid.',
),
);
}
final parameters = {
'artist': artist,
'mbid': mbid,
'limit': limit,
'autocorrect': (autoCorrect ? 1 : 0),
};
final request = Request(
api: _api,
method: 'artist.getSimilar',
parameters: parameters,
);
final response = await request.send(mode: RequestMode.GET);
final similarArtists = response['similarartists']['artist'];
return similarArtists == null
? null
: List.generate(
(similarArtists as List).length,
(i) => Artist.fromJson(similarArtists[i]),
);
}