screenShoot method

Future<void> screenShoot({
  1. bool isOverride = true,
  2. String? savedPath,
  3. int? delaySec,
  4. bool selectWindow = true,
  5. bool includeWindowBorder = false,
  6. bool includeMousePointer = false,
})

sudo apt install scrot   # Ubuntu/Debian

sudo dnf install scrot   # Fedora

sudo pacman -S scrot     # Arch

Implementation

Future<void> screenShoot({
  bool isOverride = true,
  String? savedPath,
  int? delaySec,
  bool selectWindow = true,
  bool includeWindowBorder = false,
  bool includeMousePointer = false,
}) async {
  try {
    List<String> list = [];
    if (isOverride) {
      list.add('-o');
    }
    if (delaySec != null) {
      list.add('-d');
      list.add(delaySec.toString());
    }
    if (selectWindow) {
      list.add('-s');
    }
    if (includeWindowBorder) {
      list.add('-b');
    }
    if (includeMousePointer) {
      list.add('-m');
    }

    if (savedPath != null && savedPath.isNotEmpty) {
      list.add(savedPath);
    }
    await Process.run('scrot', list);
  } catch (e) {
    debugPrint(e.toString());
  }
}