getVersion method

Version getVersion()

Returns the DartSdk's version

Implementation

Version getVersion() {
  if (_version == null) {
    final platform = Platform.version;
    final parts = platform.split(' ');

    if (parts.isEmpty) {
      throw core.DCliException('Failed to parse dart version: $platform');
    }

    final versionPart = parts[0];
    try {
      _version = Version.parse(versionPart);
    } on FormatException {
      throw core.DCliException('Failed to parse dart version: $versionPart');
    }

    verbose(() => 'Dart SDK Version  $_version');
  }

  return _version!;
}