handleShakeEvent static method
Future<void>
handleShakeEvent(
)
Implementation
static Future<void> handleShakeEvent() async {
try {
RenderRepaintBoundary? boundary = _findRepaintBoundary();
var screenList = _instance.getScreenList();
if (boundary == null) {
await methodChannel.invokeMethod(
'handleShakeEvent', {'uri': '', 'screenList': screenList});
return;
}
ui.Image image = await boundary.toImage(pixelRatio: 2.0);
ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData!.buffer.asUint8List();
String filePath = await _saveImageToFile(pngBytes);
String uri = Uri.file(filePath).toString();
await methodChannel.invokeMethod(
'handleShakeEvent', {'uri': uri, 'screenList': screenList});
} catch (e) {
if (kDebugMode) {
print("Failed to handle shake event: $e");
}
}
}