Home > Back-end >  Flutter - Extended_image_ provider package error
Flutter - Extended_image_ provider package error

Time:04-13

im trying to use extended_image_provider package to edit a photo. When i want to convert the rawImageData into Uin8list the program breaks. I really dont understand why..

Here is the function => it breaks before print('out')

Future<void> crop([bool test = true]) async {
    final ExtendedImageEditorState state = editorKey.currentState!;
    final Rect? rect = state.getCropRect();
    final EditActionDetails action = state.editAction!;
    final double radian = action.rotateAngle;

    final bool flipHorizontal = action.flipY;
    final bool flipVertical = action.flipX;
    print("in--");
    final Uint8List img =  state.rawImageData;
    print("out--");
    final ImageEditorOption option = ImageEditorOption();

    option.addOption(ClipOption.fromRect(rect!));
    option.addOption(FlipOption(horizontal: flipHorizontal, vertical: flipVertical));
    if (action.hasRotateAngle) {
      option.addOption(RotateOption(radian.toInt()));
    }

    option.addOption(ColorOption.saturation(sat));
    option.addOption(ColorOption.brightness(bright   1));
    option.addOption(ColorOption.contrast(con));

    option.outputFormat = const OutputFormat.jpeg(100);

    print(const JsonEncoder.withIndent('  ').convert(option.toJson()));

    final DateTime start = DateTime.now();
    final Uint8List? result = await ImageEditor.editImage(
      image: img,
      imageEditorOption: option,
    );

the error in log:


> Unhandled Exception:
> 'package:extended_image_library/src/extended_image_provider.dart':
> Failed assertion: line 34 pos 12: 'cacheRawData': you should set
> [ExtendedImageProvider.cacheRawData] to true, if you want to get
> rawImageData from provider.

CodePudding user response:

As it says in the error message just add cacheRawData = true to the ExtendedImageProvider.

  • Related