我尝试使用image_crop和image_cropper之类的各种库。但是它们只允许您裁剪本地图像,而我想裁剪在线图像并存储裁剪后的图像。最好的方法是什么?
答案 0 :(得分:0)
使用Flutter cached_network_image
或flutter_cache_manager
(缓存的网络映像使用flutter_cache_manager存储和检索文件),您可以从网络获取文件。
var imageFile =
await DefaultCacheManager().getSingleFile('https://your_network_image_url');
然后,您可以将此文件发送到image_cropper
进行裁剪。
Future<Null> _cropImage(File imageFile) async {
File croppedFile = await ImageCropper.cropImage(
sourcePath: imageFile.path,
ratioX: 1.0,
ratioY: 1.0,
maxWidth: 512,
maxHeight: 512,
);
}