getCorrection method

Future<List<Artist>> getCorrection({
  1. required String artist,
})

Use the last.fm corrections data to check whether the supplied artist has a correction to a canonical artist

https://www.last.fm/api/show/artist.getCorrection

Implementation

Future<List<Artist>> getCorrection({required String artist}) async {
  final parameters = {'artist': artist};

  final request = Request(
    api: _api,
    method: 'artist.getCorrection',
    parameters: parameters,
  );

  final response = await request.send(mode: RequestMode.GET);

  final corrections = response['corrections'];

  if (corrections is List) {
    return List.generate(
      corrections.length,
      (i) =>
          Artist.fromJson(response['corrections']['correction']['artist'][i]),
    );
  }

  // A list of a single correction.
  return [Artist.fromJson(corrections['correction']['artist'])];
}