繁体   English   中英

Flutter 图像裁剪器未显示要裁剪的图像

[英]Flutter image cropper not showing image to be cropped

我设法使用图像选择器从图库中选择了一张图像,如下所示

Future pickImage() async {
File _originalImage = await ImagePicker.pickImage(
    source: ImageSource.camera);
if (_originalImage != null) {
  File _croppedImage = await ImageCropper.cropImage(
      sourcePath: _originalImage.path,
      aspectRatioPresets: [
        CropAspectRatioPreset.square,
        CropAspectRatioPreset.ratio3x2,
        CropAspectRatioPreset.original,
        CropAspectRatioPreset.ratio4x3,
        CropAspectRatioPreset.ratio16x9
      ],

      androidUiSettings: AndroidUiSettings(
          toolbarColor: BaengColors.blue,
          toolbarTitle: 'Baeng Omang Cropper',
          statusBarColor: BaengColors.blue[700],
          initAspectRatio: CropAspectRatioPreset.original,
          lockAspectRatio: false
      )
  );
   this.setState(() {
     _imagePicked = _croppedImage;
     isLoaded = true;
     getTextFromImage();
    });
   } 
  }

尝试对其进行多次调试,它没有显示任何类型的错误或问题,但图像裁剪活动仍然是黑色(没有)从图像选择器中选择的图像。

请帮忙

只需在 Image_Picker 中添加 maxHeight 和 maxWidth

File  _originalImage = await ImagePicker.pickImage(source: ImageSource.camera, 
imageQuality: 20,
maxHeight: 500,maxWidth: 500);

暂无
暂无

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

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