captureAndSendToNative static method

Future<String?> captureAndSendToNative(
  1. GlobalKey<NavigatorState> navigatorKey,
  2. MethodChannel methodChannel,
  3. String methodName
)

Implementation

static Future<String?> captureAndSendToNative(
  GlobalKey<NavigatorState> navigatorKey,
  MethodChannel methodChannel,
  String methodName,
) async {
  final ScreenshotDetails? filePath = await captureAndSaveScreenshot(
    navigatorKey,
  );

  if (filePath == null) {
    return null; // Or handle the error as needed
  }

  try {
    await methodChannel.invokeMethod(methodName, filePath);
    NLogger.i('Screenshot path sent to native: $filePath');
    return filePath.filePath; // Return the path after sending to native
  } on PlatformException catch (e) {
    NLogger.i("Error sending path to native: '${e.message}'.");
    return null;
  }
}