List parseScreenshots()

in lib/src/screenshot.dart [15:65]


List<Screenshot> parseScreenshots(List? input) {
  final res = <Screenshot>[];
  if (input == null) {
    return res;
  }

  for (final e in input) {
    if (e is! Map) continue;

    final description = e['description'];
    if (description == null) {
      throw CheckedFromJsonException(
        e,
        'description',
        'Screenshot',
        'Missing required key `description`',
      );
    }

    if (description is! String) {
      throw CheckedFromJsonException(
        e,
        'description',
        'Screenshot',
        '`$description` is not a String',
      );
    }

    final path = e['path'];
    if (path == null) {
      throw CheckedFromJsonException(
        e,
        'path',
        'Screenshot',
        'Missing required key `path`',
      );
    }

    if (path is! String) {
      throw CheckedFromJsonException(
        e,
        'path',
        'Screenshot',
        '`$path` is not a String',
      );
    }

    res.add(Screenshot(description, path));
  }
  return res;
}