简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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