尝试使用 flutter RenderRepaintBoundary 截屏时出错
Error when trying to take screenshot with flutter RenderRepaintBoundary
RenderRepaintBoundary boundary = globalKey.currentContext.findRenderObject()
as RenderRepaintBoundary;
var image = await boundary.toImage(pixelRatio: pixelRatio);
boundary.toImage(pixelRatio: pixelRatio);
## 抛出错误
[ERROR:flutter/shell/common/shell.cc(242)] Dart Unhandled Exception: NoSuchMethodError: The getter '_handles' was called on null.
Receiver: null
Tried calling: _handles, stack trace: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
: #1 new Image._ (dart:ui/painting.dart:1601:12)
: #2 Scene.toImage.<anonymous closure>.<anonymous closure> (dart:ui/compositing.dart:35:24)
两周前它运行良好,但现在抛出此错误。我该如何解决?
所以基本上你遇到的问题是 boundary.toImage(pixelRatio: pixelRatio);
改为boundary.toImage();
它会很好用
RenderRepaintBoundary boundary = globalKey.currentContext.findRenderObject()
as RenderRepaintBoundary;
var image = await boundary.toImage(pixelRatio: pixelRatio);
boundary.toImage(pixelRatio: pixelRatio);
## 抛出错误
[ERROR:flutter/shell/common/shell.cc(242)] Dart Unhandled Exception: NoSuchMethodError: The getter '_handles' was called on null.
Receiver: null
Tried calling: _handles, stack trace: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
: #1 new Image._ (dart:ui/painting.dart:1601:12)
: #2 Scene.toImage.<anonymous closure>.<anonymous closure> (dart:ui/compositing.dart:35:24)
两周前它运行良好,但现在抛出此错误。我该如何解决?
所以基本上你遇到的问题是 boundary.toImage(pixelRatio: pixelRatio);
改为boundary.toImage();
它会很好用