[英]flutter image cropper can't crop images
我使用这个Github链接下载了 enigma 项目。 它使用pub.dev中的 image_cropper 进行了图像裁剪 function,因此当我尝试运行该项目时,这部分出现错误。
Future<Null> _cropImage() async {
double x, y;
if (widget.profile) {
x = 1.0;
y = 1.0;
}
File croppedFile = await ImageCropper.cropImage(
sourcePath: _imageFile.path,
ratioX: x,
ratioY: y,
circleShape: widget.profile,
toolbarColor: Colors.white);
setState(() {
if (croppedFile != null) _imageFile = croppedFile;
});
}
它说
未定义命名参数“ratioX”。 尝试将名称更正为现有命名参数的名称,或定义名称为“ratioX”的命名参数
但它与原始项目相同。
@override
Widget build(BuildContext context) {
return Enigma.getNTPWrappedWidget(WillPopScope(
child: Scaffold(
backgroundColor: enigmaBlack,
appBar: new AppBar(
title: new Text(widget.title),
backgroundColor: enigmaBlack,
actions: _imageFile != null
? <Widget>[
IconButton(
icon: Icon(Icons.edit, color: enigmaWhite),
disabledColor: Colors.transparent,
onPressed: () {
_cropImage();
}),
IconButton(
icon: Icon(Icons.check, color: enigmaWhite),
onPressed: () {
setState(() {
isLoading = true;
});
widget.callback(_imageFile).then((imageUrl) {
Navigator.pop(context, imageUrl);
});
}),
SizedBox(
width: 8.0,
)
]
: []),
body: Stack(children: [
new Column(children: [
new Expanded(child: new Center(child: _buildImage())),
_buildButtons()
]),
Positioned(
child: isLoading
? Container(
child: Center(
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(enigmaBlue)),
),
color: enigmaBlack.withOpacity(0.8),
)
: Container(),
)
]),
),
onWillPop: () => Future.value(!isLoading),
));
}
裁剪图像方法在这里使用..
Image Cropper 库有称为 ratioX 和 ratioY 的参数,但在最新版本中已更改。
检查 1.1.0 版库的变更日志:
重大变化:ratioX 和 ratioY 被 aspectRatio 取代,circleShape 被 cropStyle 取代,删除了 toolbarTitle 和 toolbarColor(这些属性被移入 AndroidUiSettings)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.