toString method

  1. @override
String toString()
override

Returns a String representation of the Version.

Uses the format "$major.$minor.$patch". If preRelease has segments available they are appended as "-segmentOne.segmentTwo", with each segment separated by a period. If build is specified, it is appended as "+build.info" where "build.info" is whatever value build is set to. If all preRelease and build are specified, then both are appended, preRelease first and build second. An example of such output would be "1.0.0-preRelease.segment+build.info".

Implementation

@override
String toString() {
  final StringBuffer output = StringBuffer("$major.$minor.$patch");
  if (_preRelease.isNotEmpty) {
    output.write("-${_preRelease.join('.')}");
  }
  if (build.trim().isNotEmpty) {
    output.write("+${build.trim()}");
  }
  return output.toString();
}