union method Null safety

  1. @override
VersionConstraint union(
  1. VersionConstraint other
)
override

Returns a VersionConstraint that allows Versions allowed by either this or other.

Implementation

@override
VersionConstraint union(VersionConstraint other) {
  if (other.allows(this)) return other;

  if (other is VersionRange) {
    if (other.min == this) {
      return VersionRange(
          min: other.min,
          max: other.max,
          includeMin: true,
          includeMax: other.includeMax,
          alwaysIncludeMaxPreRelease: true);
    }

    if (other.max == this) {
      return VersionRange(
          min: other.min,
          max: other.max,
          includeMin: other.includeMin,
          includeMax: true,
          alwaysIncludeMaxPreRelease: true);
    }
  }

  return VersionConstraint.unionOf([this, other]);
}