如何解决抖动的图像裁剪没有响应
我正在尝试从库中选取的图像中裁剪图像,图像被完美地拾取,但是在尝试裁剪图像时,屏幕上似乎没有任何反应,尽管我无法理解问题,但在控制台中检测到了一些问题。我使用的代码来自pub.dev官方网站[https://pub.dev/packages/image_cropper/example]
我的任务是:为图像选择并裁剪图像
帮助我解决此问题,谢谢。
代码:
....
class _EditGalleryScreenState extends State<EditGalleryScreen> {
File imageFile;
List _galleries = new List();
@override
void initState() {
.....
}
....
//SOME API CALLS
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Gallery"),),body: _galleries.isNotEmpty
? GridView.builder(/* DIAPLYING LIST OF IMAGES FROM API CALL */)
: SizedBox(),//BUTTON TO TRIGGER IMAGE PICKER
floatingActionButton: FloatingActionButton(
tooltip: "Add Image",onPressed: () {
_pickImage();
},child: Icon(Icons.add_a_photo),backgroundColor: AppColors.PRIMARY_COLOR,);
}
Future<Null> _pickImage() async {
// imageFile = await ImagePicker.pickImage(source: ImageSource.gallery); // this was deprecated so i have updated to otherone
PickedFile imageFile = await ImagePicker().getImage(
source: ImageSource.gallery,maxWidth: 500,maxHeight: 500,imageQuality: 20);
if (imageFile != null) {
setState(() {
state = AppState.picked;
debugPrint("Image Picked and State Changed");
_cropImage();//calling CROP FUNCTION
});
}
}
Future<Null> _cropImage() async {
debugPrint("Crop Image Called");
File croppedFile = await ImageCropper.cropImage(
sourcePath: imageFile.path,aspectRatioPresets: Platform.isAndroid
? [
CropAspectRatioPreset.square,CropAspectRatioPreset.ratio3x2,CropAspectRatioPreset.original,CropAspectRatioPreset.ratio4x3,CropAspectRatioPreset.ratio16x9
]
: [
CropAspectRatioPreset.original,CropAspectRatioPreset.square,CropAspectRatioPreset.ratio5x3,CropAspectRatioPreset.ratio5x4,CropAspectRatioPreset.ratio7x5,CropAspectRatioPreset.ratio16x9
],androidUiSettings: AndroidUiSettings(
toolbarTitle: 'Cropper',toolbarColor: Colors.deepOrange,toolbarWidgetColor: Colors.white,initAspectRatio: CropAspectRatioPreset.original,lockAspectRatio: false),iosUiSettings: IOSUiSettings(
title: 'Cropper',));
if (croppedFile != null) {
imageFile = croppedFile;
setState(() {
state = AppState.cropped;
});
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。