queryArtwork method
Future<Uint8List?>
queryArtwork(
- int id,
- ArtworkType type, {
- ArtworkFormat? format,
- int? size,
- int? quality,
override
Used to return Songs Artwork.
Parameters:
type
is used to define if artwork is from audios or albums.format
is used to define typePNG
orJPEG
.size
is used to define image quality.
Usage and Performance:
- Using
PNG
will return a better image quality but a slow performance. - Using Size greater than 200 probably won't make difference in quality but will cause a slow performance.
Important:
- This method is only necessary for API >= 29
Android Q/10
. - If queryArtwork is called in Android below Q/10, will return null.
- If
format
is null, will be set toJPEG
for better performance. - If
size
is null, will be set to200
for better performance - We need this method separated from
querySongs/queryAudios
because return Uint8List and using inside query causes a slow performance.
Platforms:
Android | IOS | Web |
---|---|---|
✔️ |
✔️ |
✔️ |
See more about platforms support
Implementation
@override
Future<Uint8List?> queryArtwork(
int id,
ArtworkType type, {
ArtworkFormat? format,
int? size,
int? quality,
}) async {
final Uint8List? finalArtworks = await _channel.invokeMethod(
"queryArtwork",
{
"type": type.index,
"id": id,
"format": format != null ? format.index : ArtworkFormat.JPEG.index,
"size": size ?? 200,
"quality": (quality != null && quality <= 100) ? quality : 50,
},
);
return finalArtworks;
}