capturePng static method
Implementation
static Future<String> capturePng(RenderRepaintBoundary boundary) async {
final ui.Image image = await boundary.toImage(pixelRatio: 3.0);
final byteData = await image.toByteData(format: ui.ImageByteFormat.png);
if (byteData == null) {
throw Exception('Failed to capture canvas screenshot');
}
final pngBytes = byteData.buffer.asUint8List();
final directory = await getTemporaryDirectory();
final fileName = 'snap_map_${DateTime.now().millisecondsSinceEpoch}.png';
final file = File('${directory.path}/$fileName');
await file.writeAsBytes(pngBytes);
return file.path;
}