Search code examples
imageflutter-web

Flutter web: Error when changing the RenderRepaintBoundary to image


I got this error when I used the RepaintBoundary widget and changed it to image by

final boundary = _repaintBoundaryKey.currentContext?.findRenderObject()
        as RenderRepaintBoundary?;
    final image = await boundary?.toImage(); 

Error: Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/html/scene_builder.dart:94:16
matrix4[0] == window.devicePixelRatio &&
            matrix4[5] == window.devicePixelRatio

I find the cause of this error that is

final image = await boundary?.toImage();

How to fix this?


Solution

  • Yes, I found this on Github and forgot to close this. Just build with flutter build web --web-renderer canvaskit.