fluttercandies / flutter_image_editor

Flutter plugin, support android/ios.Support crop, flip, rotate, color martix, mix image, add text. merge multi images.
Apache License 2.0
421 stars 129 forks source link

An exception while trying to rotate #64

Closed senselesscn closed 2 years ago

senselesscn commented 3 years ago

Lib Version:1.0.0 environment:>=2.7.0 <3.0.0 Platform:Android Platform Version:29 Target Version:29 Exception:

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(java.lang.IllegalStateException: bitmap must not be null
        at top.kikt.flutter_image_editor.FlutterImageEditorPlugin.getBitmap(FlutterImageEditorPlugin.kt:144)
        at top.kikt.flutter_image_editor.FlutterImageEditorPlugin.handle(FlutterImageEditorPlugin.kt:207)
        at top.kikt.flutter_image_editor.FlutterImageEditorPlugin.access$handle(FlutterImageEditorPlugin.kt:25)
        at top.kikt.flutter_image_editor.FlutterImageEditorPlugin$onMethodCall$$inlined$runOnBackground$1.run(FlutterImageEditorPlugin.kt:236)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
    , , null, null)
    #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7)
    #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
    <asynchronous suspension>
    #2      NativeChannel.memoryToMemory (package:image_editor/src/channel.dart:39:20)
    <asynchronous suspension>
    #3      ImageEditor.editImage (package:image_editor/src/editor.dart:28:13)
    <asynchronous suspension>
    #4      PreViewPhotoPageState.loadImage (package:institute_flutter/page/preview_page.dart:209:24)
    <asynchronous suspension>

code:

    //网络加载图片,正常工作
    ui.Image _image = await loadImageByProvider(NetworkImage(url));
    final byteData = await _image.toByteData();
    assert(byteData != null);
    final bytes = byteData.buffer.asUint8List();
    final op = ImageEditorOption();
    op.addOption(RotateOption(270));
    op.outputFormat = OutputFormat.png();
    //输入是正常的
    assert(bytes != null);
    final result = await ImageEditor.editImage(image: bytes, imageEditorOption: op);