Reputation: 1437
Looking for a simple and fast example / tutorial to composite / overlay several images in Flutter, using (PNG) images from the assets directory:
Few options I've examined:
Couldn't find any working example that suits my needs... I'd appreciate any working example / tutorial that will help me, thanks!
Upvotes: 1
Views: 1027
Reputation: 7601
4.Use combination of Stack and RepaintBoundary to generate new image:
Future<Uint8List> _takeScreenShot(context) async {
RenderRepaintBoundary boundary = _repaintKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage(pixelRatio: 2.0);
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
return pngBytes;
}
Stack(
key: _repaintKey,
children: [
//your background image,
//your png image,
],
)
Upvotes: 2