getSdkPath function
Get the Dart SDK path.
The result is cached since the SDK path cannot change during a process lifetime.
Tries in order:
- DART_SDK environment variable
- Platform.resolvedExecutable (reliable when running via
dart) - Shell out to
dartto resolve its executable path (when AOT-compiled)
Implementation
String getSdkPath() => _cachedSdkPath ??= _resolveSdkPath();