简体   繁体   English

flutter 图片裁剪器无法裁剪图片

[英]flutter image cropper can't crop images

I downloaded enigma project using this Github link.我使用这个Github链接下载了 enigma 项目。 It has image crop function using image_cropper from pub.dev so when I trying to run this project I am getting an error from this part.它使用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;
    });
  }

It says它说

The named parameter 'ratioX' isn't defined.未定义命名参数“ratioX”。 Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'ratioX'尝试将名称更正为现有命名参数的名称,或定义名称为“ratioX”的命名参数

but it's the same as the original project.但它与原始项目相同。

 @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),
    ));
  }

crop image method uses here..裁剪图像方法在这里使用..

Image Cropper library had parameters called ratioX and ratioY, but it has been changed in recent versions. Image Cropper 库有称为 ratioX 和 ratioY 的参数,但在最新版本中已更改。

Check the CHANGELOG of the libary at version 1.1.0:检查 1.1.0 版库的变更日志:

BREAKING CHANGE: ratioX and ratioY are replaced by aspectRatio, circleShape is replaced by cropStyle, removed toolbarTitle and toolbarColor (these properties are moved into AndroidUiSettings)重大变化:ratioX 和 ratioY 被 aspectRatio 取代,circleShape 被 cropStyle 取代,删除了 toolbarTitle 和 toolbarColor(这些属性被移入 AndroidUiSettings)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM