filesFor method

List<PlaybookScreenshotFile> filesFor(
  1. Map<String, Object?> event
)

The screenshots event reported, with where each one is saved.

Implementation

List<PlaybookScreenshotFile> filesFor(Map<String, Object?> event) {
  final int depth = _depthOf(event);
  switch (event['event']) {
    case 'begin' when event['group'] == true:
      _groups.add((
        depth: depth,
        index: event['index'],
        name: '${event['name']}',
      ));
    case 'step':
      // A group's own line can carry the screen of a failure that
      // happened before any of its steps ran.
      if (event['group'] == true &&
          _groups.isNotEmpty &&
          _groups.last.depth == depth &&
          _groups.last.index == event['index']) {
        _groups.removeLast();
      }
      final Object? shots = event['shots'];
      if (shots is! List) return const [];
      return [
        for (final Object? shot in shots)
          if (shot is Map && shot['id'] is String)
            _file(event, depth, Map<String, Object?>.from(shot)),
      ];
  }
  return const [];
}