validateRuntimes method

void validateRuntimes(
  1. List<Runtime> allRuntimes
)

Throws a FormatException if this refers to any undefined runtimes.

Implementation

void validateRuntimes(List<Runtime> allRuntimes) {
  var validVariables =
      allRuntimes.map((runtime) => runtime.identifier).toSet();
  _metadata.validatePlatformSelectors(validVariables);

  var runtimes = _runtimes;
  if (runtimes != null) {
    for (var selection in runtimes) {
      if (!allRuntimes
          .any((runtime) => runtime.identifier == selection.name)) {
        if (selection.span != null) {
          throw SourceSpanFormatException(
              'Unknown platform "${selection.name}".', selection.span);
        } else {
          throw FormatException('Unknown platform "${selection.name}".');
        }
      }
    }
  }

  onPlatform.forEach((selector, config) {
    selector.validate(validVariables);
    config.validateRuntimes(allRuntimes);
  });
}