captureAndSave method

Future<File?> captureAndSave({
  1. double? pixelRatio,
  2. Duration delay = const Duration(milliseconds: 20),
})

Create screenshot and save it in file. File will be created in directory specified in TrackerOptions.

Implementation

Future<File?> captureAndSave({
  double? pixelRatio,
  Duration delay = const Duration(milliseconds: 20),
}) async {
  try {
    if (_path?.isEmpty == true) {
      return null;
    }
    final Uint8List? content = await _capture(
      pixelRatio: pixelRatio,
      delay: delay,
    );

    if (content != null) {
      return saveFile(content);
    }
    return null;
  } catch (exception) {
    _logger.warning("Failed to create screenshot file: $exception");
  }
  return null;
}