parseVersion static method

VersionConstraint parseVersion(
  1. ConfigReader reader
)

Reads only the version constraint, so a version mismatch is reported before anything else in the file.

Implementation

static VersionConstraint parseVersion(ConfigReader reader) {
  final raw = reader.requiredString('version');
  try {
    return VersionConstraint.parse(raw);
  } on FormatException {
    throw reader.valueError(
      'version',
      '"$raw" is not a version constraint. Use one like ^1.0.0.',
    );
  }
}