flutter 将视图Widget 生成成Png 流程
将需要生成图片的Widget 使用RepaintBoundary包裹起来,并给定globalkey。
通过globalKey获取renderObject .转成图就好
RepaintBoundary(
key: PageManageUtil().generateKey(pageIndex),
child: _inheritedInfo.dmsStackViewFromMap[pageIndex],
)
RenderRepaintBoundary boundary = _pageGlobalKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.rawRgba);
Uint8List _uInt8List = byteData.buffer.asUint8List();
Image.memory(_uInt8List, width: 100, height: 177)