0
  Future<String> saveImageToDevice({required String songId}) async {
    final dirPath =
        join((await getApplicationSupportDirectory()).path, '$songId');
    var bytesToWrite;
    var songImageBytes =
        await audioQuery.queryArtwork(int.parse(songId), ArtworkType.AUDIO);
    if (songImageBytes != null) {
      bytesToWrite = songImageBytes.buffer.asUint8List(
          songImageBytes.offsetInBytes, songImageBytes.lengthInBytes);
    } else if (songImageBytes == null) {
      bytesToWrite = assetImageBytes.buffer.asUint8List(
          assetImageBytes.offsetInBytes, assetImageBytes.lengthInBytes);
    } else {
      bytesToWrite = anotherAssetBytes.buffer
          .asUint8List(anotherAssetBytes.offsetInBytes, anotherAssetBytes.lengthInBytes);
    }
    await File(dirPath).create(recursive: true)
      ..writeAsBytes(bytesToWrite);
    return dirPath;
  }

以上是我用于将图像字节保存在本地存储中并 artUri: Uri.file(artPath)用于展示艺术的代码。

我真的不知道这是插件(audio_service)或我的代码的错误。

4

0 回答 0