findSdkPath function

String? findSdkPath()

Locates a Dart SDK root, probing in order: the running VM's executable, the DART_SDK environment variable, dart binaries on PATH (including Flutter checkouts, whose wrapper script hides the SDK under bin/cache/dart-sdk), FLUTTER_ROOT, and standard system SDK locations.

Returns null when no valid SDK is found — notably when running as a standalone AOT executable (dart compile exe), where Platform.resolvedExecutable is the tool binary itself.

Implementation

String? findSdkPath() =>
    _findSdkFromExecutable() ??
    _findSdkFromEnv() ??
    _findSdkFromPath() ??
    _findSdkFromFlutterRoot() ??
    _findSdkFromStandardLocations();