最近项目中因为多图片选择,需要获取图片的绝对路径,以便调用极光接口进行发送
然后multi_image_picker插件并没有绝对路径,而是媒体路径
咨询大神之后,发现了可以使用:# flutter_wechat_assets_picker这个插件。
获取图片绝对路径示例:
Future<void> selectAssets() async {
final Set<AssetEntity> result = await AssetPicker.pickAssets(
context,
maxAssets: 9,
pathThumbSize: 84,
gridCount: 4,
selectedAssets: assets,
);
if (result != null) {
assets = Set<AssetEntity>.from(result);
print(assets.first);
AssetEntity asset = assets.first;
File file = await asset.file;
print(file.path);
}
}
print结果:
I/flutter (22807): AssetEntity{id:532827}
I/flutter (22807): /storage/emulated/0/DCIM/Screenshots/Screenshot_2020-02-15-21-49-57-912_com.kiss_you_5g.jpg
这个插件在https://pub.flutter-io.cn/上,名称为:wechat_assets_picker
网友评论