我需要得到的图像使用图像拾取器插件,我需要转换这些图像为WebP使用Flutter 翼,图像拾取器已完成,现在我需要转换图像为WebP,以减少图像大小
this is my code to get the image ,also i added allowCompression: true to reduce the size but ,it doesnt convert the image to webp
Future<void> _pickImages() async {
List<File> resultList = [];
try {
FilePickerResult? result = await FilePicker.platform.pickFiles(
allowCompression: true,
type: FileType.custom,
allowMultiple: true,
allowedExtensions: ['jpg', 'png', 'jpeg'],
);
if (result != null) {
resultList = result.paths.map((path) => File(path!)).toList();
} else {
// User canceled the picker
return;
}
} catch (e) {
print(e.toString());
return;
}
if (!mounted) return;
// setState(() {
for (var i = 0; i < resultList.length; i++) {
bool isComply = await CommonMethods.isImageHorizontal(resultList[i]);
// Check if the image is horizontal
if (isComply) {
if (!selectedImages.contains(resultList[i].path)) {
selectedImages.add(resultList[i].path);
} else {
Logger().wtf("File Already Exist");
}
} else {
// Show an error for non-horizontal images
}
}
// });
setState(() {});
}