Home > OS >  'Future<Uint8List?>' can't be assigned to the parameter type 'Uint8List�
'Future<Uint8List?>' can't be assigned to the parameter type 'Uint8List�

Time:07-30

I have the below code that is querying artwork from https://pub.dev/packages/on_audio_query It is able to get the artwork in Future<Uint8List?> formart. How can I convert that to Uint8List?

  Future<Uint8List?> getArtWork(id)async{
    return await _audioQuery.queryArtwork(id,ArtworkType.AUDIO);
  }

Uint8List uint8List =  getArtWork(metadata.id.toString())

CodePudding user response:

use await to get the Uint8List?

Uint8List? uint8List =  await getArtWork(metadata.id.toString())

CodePudding user response:

Your getArtWork can return null and uint8List variable doesnt accept nullable data.

You can make it nullable

youMethod() async{
   Uint8List? uint8List =  await getArtWork(metadata.id.toString());
}
  • Related