queryArtworks method

Future<Uint8List?> queryArtworks(
  1. int id,
  2. ArtworkType type, [
  3. ArtworkFormat? format,
  4. int? size,
  5. bool? requestPermission,
])

Used to return Songs Artwork.

Parameters:

  • requestPermission is used for request or no Android STORAGE PERMISSION.
  • type is used to define if artwork is from audios or albums.
  • format is used to define type PNG or JPEG.
  • 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 queryArtworks is called in Android below Q/10, will return null.
  • If requestPermission is null, will be set to false.
  • If format is null, will be set to JPEG for better performance.
  • If size is null, will be set to 200 for better performance
  • We need this method separated from querySongs/queryAudios because return Uint8List and using inside query causes a slow performance.

Implementation

Future<Uint8List?> queryArtworks(
  int id,
  ArtworkType type, [
  ArtworkFormat? format,
  int? size,
  bool? requestPermission,
]) async {
  final Uint8List? finalArtworks =
      await _channel.invokeMethod("queryArtworks", {
    "requestPermission": _checkPermission(requestPermission),
    "type": type.index,
    "id": id,
    "format": format != null ? format.index : ArtworkFormat.JPEG.index,
    "size": size != null ? size : 200
  });
  return finalArtworks;
}