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 CatcherOptions.

Implementation

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

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