简体   繁体   English

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

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

I managed to choose an image from gallery using the image picker and it is as follows我设法使用图像选择器从图库中选择了一张图像,如下所示

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();
    });
   } 
  }

Tried to debug it several times and it was not showing any kind of bug nor problem, but the image cropping activity remains black(without) the image selected from the image picker.尝试对其进行多次调试,它没有显示任何类型的错误或问题,但图像裁剪活动仍然是黑色(没有)从图像选择器中选择的图像。

Please help请帮忙

Just add maxHeight And maxWidth in Image_Picker只需在 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