Repository navigation
Move toImage() impl from RepaintRenderBoundary to OffsetLayer - #17060
Conversation
| /// | ||
| /// See also: | ||
| /// | ||
| /// * [dart:ui.Scene.toImage] for more information about the image returned. |
There was a problem hiding this comment.
Also point to RenderRepaintBoundary
| /// | ||
| /// See also: | ||
| /// | ||
| /// * [dart:ui.Scene.toImage] for more information about the image returned. |
There was a problem hiding this comment.
I'd add a pointer here to the toImage in RenderRepaintBoundary too.
| @@ -2473,24 +2473,9 @@ class RenderRepaintBoundary extends RenderProxyBox { | |||
| /// See also: | |||
| /// | |||
| /// * [dart:ui.Scene.toImage] for more information about the image returned. | |||
There was a problem hiding this comment.
Also add a pointer to your new function on the layer.
| /// | ||
| /// * [dart:ui.Scene.toImage] for more information about the image returned. | ||
| Future<ui.Image> toImage(Size logicalSize, {double pixelRatio: 1.0}) async { | ||
| final ui.SceneBuilder builder = new ui.SceneBuilder(); |
| @@ -2473,24 +2473,9 @@ class RenderRepaintBoundary extends RenderProxyBox { | |||
| /// See also: | |||
There was a problem hiding this comment.
would be good to have some sample code here showing how you go from a GlobalKey on a RepaintBoundary to a PNG.
| import 'package:vector_math/vector_math_64.dart'; | ||
|
|
||
| import 'debug.dart'; | ||
| import 'proxy_box.dart' show RenderRepaintBoundary; |
There was a problem hiding this comment.
(if you just added this for the docs, you can remove it, dartdoc will figure it out magically)
| /// `RepaintBoundary` to a PNG: | ||
| /// | ||
| /// ```dart | ||
| /// class PngApp extends StatelessWidget { |
There was a problem hiding this comment.
you can drop this class, it doesn't add anything to the sample
| /// class PngHome extends StatefulWidget { | ||
| /// PngHome({Key key, this.title}) : super(key: key); | ||
| /// | ||
| /// final String title; |
| /// ui.Image image = await boundary.toImage(); | ||
| /// ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png); | ||
| /// Uint8List pngBytes = byteData.buffer.asUint8List(); | ||
| /// print(pngBytes); |
There was a problem hiding this comment.
maybe write them to disk rather than to the console? :-P
There was a problem hiding this comment.
But then they'd go to device disk... and I should really use the path_provider plugin, and the example gets dramatically more complicated..
| /// tooltip: 'Capture PNG', | ||
| /// onPressed: _capturePng, | ||
| /// ), | ||
| /// ); |
There was a problem hiding this comment.
to keep this briefer, remove the scaffold, leaving only the repaint boundary, and replace the text widget with a FlatButton that does what the FAB is doing in your example. So it's a button that takes a screenshot of itself.
|
Looks like https://build.chromium.org/p/client.flutter/builders/Linux/builds/5734/steps/run%20test.dart%20for%20coverage%20shard/logs/stdio failure was not a flake after all. |
|
Known flake -- #16839 |

#16859