performChecks method
Runs the doctor check logic without launching the UI.
Implementation
DoctorViewResult performChecks({Directory? root}) {
root ??= Directory.current;
final pubspecFile = File(p.join(root.path, 'pubspec.yaml'));
if (!pubspecFile.existsSync()) {
return DoctorViewResult(
pluginName: 'unknown',
sections: [],
errors: 0,
warnings: 0,
errorMessage: 'No pubspec.yaml found. Run from the root of a Flutter plugin.',
);
}
final ctx = _DoctorCtx(root, _pluginName(pubspecFile), _findSpecs(root: root));
_checkSystemToolchain(ctx);
_checkPubspec(ctx);
// ── Apple SPM ──────────────────────────────────────────────────────────────
final spmStatus = detectSpmStatus(root.path);
_checkAppleSpm(ctx, spmStatus);
_checkGeneratedFiles(ctx);
_checkCmake(ctx);
// Whether any / all specs use NativeImpl.cpp — used below to skip irrelevant checks.
final allSpecsCpp = ctx.specs.isNotEmpty && ctx.specs.every(isCppModule);
final hasAnyCppSpec = ctx.specs.any(isCppModule);
final hasAnyNonCppSpec = ctx.specs.any((s) => !isCppModule(s));
_checkAndroid(ctx, allSpecsCpp, hasAnyNonCppSpec);
_checkIos(ctx, spmStatus, allSpecsCpp, hasAnyNonCppSpec);
_checkMacos(ctx, spmStatus, allSpecsCpp, hasAnyNonCppSpec);
// When the platform CMakeLists delegates to src/, check src/CMakeLists.txt
// as the authoritative source of truth for dart_api_dl.c / bridge.g.cpp.
final srcCmake = File(p.join(root.path, 'src', 'CMakeLists.txt'));
final srcCmakeContent = srcCmake.existsSync() ? srcCmake.readAsStringSync() : '';
_checkWindows(ctx, srcCmakeContent);
_checkLinux(ctx, srcCmakeContent);
if (hasAnyCppSpec) _checkCppDirect(ctx);
_checkCocoaPodsPermissions(ctx);
_checkExampleApp(ctx);
_checkBuildRunnerHazard(ctx);
return DoctorViewResult(
pluginName: ctx.pluginName,
sections: ctx.sections,
errors: ctx.errors,
warnings: ctx.warnings,
);
}