saveAsUint8List method
Implementation
Future<Uint8List?> saveAsUint8List() async {
clearAllBorders();
try {
Uint8List? pngBytes;
double pixelRatio = 2;
await Future.delayed(const Duration(milliseconds: 700))
.then((value) async {
RenderRepaintBoundary boundary =
AlphaStickerListWidget.globalKey.currentContext?.findRenderObject()
as RenderRepaintBoundary;
ui.Image image = await boundary.toImage(pixelRatio: pixelRatio);
ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
pngBytes = byteData?.buffer.asUint8List();
});
return pngBytes;
} catch (e) {
rethrow;
}
}