constraintAllows method

bool constraintAllows(
  1. String constraint,
  2. String version
)

Check if a target version would satisfy the given constraint.

Useful for checking if a pubspec.yaml constraint needs updating.

Implementation

bool constraintAllows(String constraint, String version) {
  try {
    return VersionConstraint.parse(constraint)
        .allows(Version.parse(version));
  } catch (_) {
    return false;
  }
}