getCoverArtUrl function Null safety
Directly get Cover art details of a manga with mangaId
and return a String containing a url to the cover page
The res
parameter can be used to change resolution of the cover art obtained
The res
parameter only supports values 256 and 512
The resolution remains unchanged if any other value of res
is given.
Implementation
Future<String> getCoverArtUrl(String mangaId, {int? res}) async {
var reso = res ?? '';
var data = await getCoverArt(mangaId);
var filename = data.data[0].attributes.fileName;
if (reso == 256 || reso == 512) {
return 'https://uploads.mangadex.org/covers/$mangaId/$filename.$reso.jpg';
} else {
return 'https://uploads.mangadex.org/covers/$mangaId/$filename';
}
}