WorkspaceTarget.fromMap constructor

WorkspaceTarget.fromMap(
  1. String id,
  2. Map<Object?, Object?> value
)

Implementation

factory WorkspaceTarget.fromMap(String id, Map<Object?, Object?> value) {
  final rawPackages = value['packages'];
  if (rawPackages is! List) {
    throw FormatException('target $id requires packages');
  }
  return WorkspaceTarget(
    id: id,
    language: _requiredString(value, 'language'),
    framework: _requiredString(value, 'framework'),
    packages: [
      for (final raw in rawPackages)
        if (raw is Map)
          WorkspacePackage.fromMap(Map<Object?, Object?>.from(raw))
        else
          throw FormatException('target $id package must be a mapping'),
    ],
  );
}