簡體   English   中英

flutter 圖片裁剪器無法裁剪圖片

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM