WorkspaceRunner.fromMap constructor

WorkspaceRunner.fromMap(
  1. Map<Object?, Object?> value
)

Implementation

factory WorkspaceRunner.fromMap(Map<Object?, Object?> value) {
  final rawArgs = value['args'];
  final rawEvidenceTypes = value['evidenceTypes'];
  if (rawArgs != null &&
      (rawArgs is! List || rawArgs.any((item) => item is! String))) {
    throw const FormatException('runner args must be string values');
  }
  if (rawEvidenceTypes != null &&
      (rawEvidenceTypes is! List ||
          rawEvidenceTypes.any((item) => item is! String))) {
    throw const FormatException('runner evidenceTypes must be string values');
  }
  final executable = value['executable'];
  if (executable != null && executable is! String) {
    throw const FormatException('runner executable must be a string');
  }
  return WorkspaceRunner(
    id: _requiredString(value, 'id'),
    target: _requiredString(value, 'target'),
    sourcePackage: _requiredString(value, 'sourcePackage'),
    sourceAdapter: _requiredString(value, 'sourceAdapter'),
    sourceCompatibilityId: _requiredString(value, 'sourceCompatibilityId'),
    runnerCompatibilityId: _requiredString(value, 'runnerCompatibilityId'),
    executable: executable as String?,
    args: rawArgs == null
        ? const []
        : (rawArgs as List).whereType<String>().toList(),
    evidenceTypes: rawEvidenceTypes == null
        ? const []
        : (rawEvidenceTypes as List).whereType<String>().toList(),
  );
}