String toString()

in lib/src/version_range.dart [430:471]


  String toString() {
    var buffer = StringBuffer();

    final min = this.min;
    if (min != null) {
      buffer
        ..write(includeMin ? '>=' : '>')
        ..write(min);
    }

    final max = this.max;

    if (max != null) {
      if (min != null) buffer.write(' ');
      if (includeMax) {
        buffer
          ..write('<=')
          ..write(max);
      } else {
        buffer.write('<');
        if (max.isFirstPreRelease) {
          // Since `"<$max"` would parse the same as `"<$max-0"`, we just emit
          // `<$max` to avoid confusing "-0" suffixes.
          buffer.write('${max.major}.${max.minor}.${max.patch}');
        } else {
          buffer.write(max);

          // If `">=$min <$max"` would parse as `">=$min <$max-0"`, add `-*` to
          // indicate that actually does allow pre-release versions.
          var minIsPreReleaseOfMax = min != null &&
              min.isPreRelease &&
              equalsWithoutPreRelease(min, max);
          if (!max.isPreRelease && max.build.isEmpty && !minIsPreReleaseOfMax) {
            buffer.write('-∞');
          }
        }
      }
    }

    if (min == null && max == null) buffer.write('any');
    return buffer.toString();
  }