installed static method

FlutterSdk? installed(
  1. String version, {
  2. String? projectRoot,
  3. Map<String, String>? environment,
})

An SDK of Flutter version on this machine, or null. Looks in the folder just installs SDKs in (UserPaths.flutterDir), then FLUTTER_ROOT, the SDK that last ran pub in projectRoot, flutter on the PATH, and the SDKs fvm keeps ($FVM_CACHE_PATH/versions or ~/fvm/versions; only read, never written).

Implementation

static FlutterSdk? installed(
  String version, {
  String? projectRoot,
  Map<String, String>? environment,
}) {
  final env = environment ?? Platform.environment;
  final own = UserPaths.flutterDir(environment: env);
  final candidates = [
    if (own != null) '$own/$version',
    env['FLUTTER_ROOT'],
    if (projectRoot != null) PackageConfig.read(projectRoot)?.flutterRoot,
    _fromPath(env),
    for (final fvm in _fvmFolders(env)) '$fvm/versions/$version',
  ];
  for (final c in candidates) {
    if (c == null || c.isEmpty) continue;
    final sdk = FlutterSdk(c);
    if (sdk.exists && sdk.isFinished && sdk.isVersion(version)) return sdk;
  }
  return null;
}