Fix union of version ranges
diff --git a/lib/src/version_range.dart b/lib/src/version_range.dart
index 2c40884..78cd6d0 100644
--- a/lib/src/version_range.dart
+++ b/lib/src/version_range.dart
@@ -243,8 +243,10 @@
     if (other is VersionRange) {
       // If the two ranges don't overlap, we won't be able to create a single
       // VersionRange for both of them.
-      var edgesTouch = (max == other.min && (includeMax || other.includeMin)) ||
-          (min == other.max && (includeMin || other.includeMax));
+      var edgesTouch = (max != null &&
+              max == other.min &&
+              (includeMax || other.includeMin)) ||
+          (min != null && min == other.max && (includeMin || other.includeMax));
       if (!edgesTouch && !allowsAny(other)) {
         return VersionConstraint.unionOf([this, other]);
       }
diff --git a/test/version_range_test.dart b/test/version_range_test.dart
index bf280c2..67c7f35 100644
--- a/test/version_range_test.dart
+++ b/test/version_range_test.dart
@@ -562,6 +562,29 @@
       expect(result, allows(v140));
     });
 
+    test('returns a VersionUnion for a disjoint range with infinite end', () {
+      void isVersionUnion(VersionConstraint constraint) {
+        expect(constraint, allows(v080));
+        expect(constraint, doesNotAllow(v123));
+        expect(constraint, allows(v140));
+      }
+
+      for (final includeAMin in [true, false]) {
+        for (final includeAMax in [true, false]) {
+          for (final includeBMin in [true, false]) {
+            for (final includeBMax in [true, false]) {
+              final a = VersionRange(
+                  min: v130, includeMin: includeAMin, includeMax: includeAMax);
+              final b = VersionRange(
+                  max: v114, includeMin: includeBMin, includeMax: includeBMax);
+              isVersionUnion(a.union(b));
+              isVersionUnion(b.union(a));
+            }
+          }
+        }
+      }
+    });
+
     test('considers open ranges disjoint', () {
       var result = VersionRange(min: v003, max: v114)
           .union(VersionRange(min: v114, max: v200));