通过 Asset in flutter 获取选定的图像路径?

Get selected image path through Asset in flutter?

我使用了 multi_image_picker: 到 select 内部存储的图像。这个库returnsList of Asset,但是我想作为图片路径,我用了FlutterAbsolutePath

var path = await FlutterAbsolutePath.getAbsolutePath(resultList[i].identifier);

但这不支持空安全,我如何使用类似的库获取图像路径?

FlutterAbsolutePath 不支持空安全

我使用按钮单击事件从资源中获取图像路径

floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),

        onPressed: () async {

              final key = DateTime.now().toString();
              File file = await getImageFileFromAssets(images[1]);

              for(int i=0;i<images.length;i++)
                {
                  print('# file path is ${file.path} #');
                }

        },
      ),

Asset转图片路径的方法

Future<File> getImageFileFromAssets(Asset asset) async {
    final byteData = await asset.getByteData();

    final tempFile =
    File("${(await getTemporaryDirectory()).path}/${asset.name}");
    final file = await tempFile.writeAsBytes(
      byteData.buffer
          .asUint8List(byteData.offsetInBytes, byteData.lengthInBytes),);

    return file;
  }