writeToFile method
Implementation
Future<void> writeToFile(
ui.Picture picture, String fileName, Size size) async {
_ScaleFactor scale = calculateScaleFactor(size);
ByteData? byteData = await ((await picture.toImage(
(scale.x *
this.debugOptions.resolutionFactor *
this.pathBoundingBox.width)
.round(),
(scale.y *
this.debugOptions.resolutionFactor *
this.pathBoundingBox.height)
.round()))
.toByteData(format: ui.ImageByteFormat.png));
if (byteData == null) return;
final buffer = byteData.buffer;
await File(fileName).writeAsBytes(
buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
print("File: $fileName written.");
}