captureScreenShotWithAppName static method

Future<ScreenShotModel> captureScreenShotWithAppName({
  1. int maxBytes = 400 * 1024,
  2. bool compress = true,
  3. bool isConvertBase64 = true,
})

Implementation

static Future<ScreenShotModel> captureScreenShotWithAppName(
    {int maxBytes = 400 * 1024,
    bool compress = true,
    bool isConvertBase64 = true}) async {
  var windowInfo = await Future.microtask(ActiveWindowPlatform.instance.getActiveWindow);
  if (windowInfo == null || (windowInfo.appName == null || (windowInfo.appName?.isEmpty ?? false)) || (windowInfo.title.isEmpty)) {
    await Future.delayed(Durations.medium3);
    windowInfo = await Future.microtask(ActiveWindowPlatform.instance.getActiveWindow);
  }
  var screenshot = await Future.microtask(DesktopScreenshotPlatform.instance.getScreenshot);
  var screenShotData = await f.compute(_compress1,
      [screenshot, maxBytes]);
  var base64 =
      (isConvertBase64) ? await f.compute(convertBase64, screenShotData) : "";
  return ScreenShotModel.name(screenShotData, windowInfo, base64);
}