getCoverArtUrlMap function

Map<String, String> getCoverArtUrlMap(
  1. Search searchData
)

Directly get Cover art details of a manga with mangaIds and return a Map<String, String> containing values with manga IDs mapped to their cover art filenames.

Implementation

Map<String, String> getCoverArtUrlMap(Search searchData) {
  // var data = await search(
  //     ids: mangaIds,
  //     includes: ['cover_art'],
  //     orders: {SearchOrders.followedCount: OrderDirections.descending});

  var map = <String, String>{};

  for (final manga in searchData.data!) {
    final searchVal = manga.relationships
        ?.where((element) => element.attributes != null)
        .toList();
    map.addEntries(
      [
        MapEntry(manga.id!, searchVal![0].attributes!.fileName!),
      ],
    );
  }

  print('''
Note this function only gives a Map of the manga ids mapped to their cover filenames.
You must use constructPageUrl() in utils and pass the map to it to get the urls. ''');

  return map;
}