getSdkPath function

String getSdkPath()

Get the Dart SDK path.

The result is cached since the SDK path cannot change during a process lifetime.

Tries in order:

  1. DART_SDK environment variable
  2. Platform.resolvedExecutable (reliable when running via dart)
  3. Shell out to dart to resolve its executable path (when AOT-compiled)

Implementation

String getSdkPath() => _cachedSdkPath ??= _resolveSdkPath();