find static method
locate, and when that finds nothing, the SDK the first flutter on
the PATH says it runs (flutterRoot from flutter --version --machine): how a snap's launcher, or a version manager's shim, is
found. The launcher gets timeout (a first run can set its SDK up
for minutes); then it is stopped, with what it started, and taken as
not knowing. Its answer is kept for the rest of this process.
Implementation
static Future<FlutterSdk?> find(
String projectRoot, {
String? configured,
Map<String, String>? environment,
Duration timeout = const Duration(seconds: 20),
}) async {
final env = environment ?? Platform.environment;
final found = locate(projectRoot, configured: configured, environment: env);
if (found != null) return found;
final launcher = _launchers(env).firstOrNull;
if (launcher == null || _asked.containsKey(launcher)) return null;
final root = _asked[launcher] = await _askLauncher(launcher, env, timeout);
return root != null && FlutterSdk(root).exists ? FlutterSdk(root) : null;
}