load static method
Loads all *.yaml files from the bundled sdk_data directory, then applies
an optional project override file. Overrides win on conflict.
Implementation
static Future<SdkDatabase> load({
Directory? sdkDataDir,
File? overridesFile,
}) async {
final dir = sdkDataDir ?? await resolveBundledSdkDataDir();
final entries = <String, SdkEntry>{};
if (!dir.existsSync()) {
throw StateError('SDK data directory not found: ${dir.path}');
}
final files =
dir
.listSync()
.whereType<File>()
.where((f) => f.path.endsWith('.yaml') || f.path.endsWith('.yml'))
.toList()
..sort((a, b) => a.path.compareTo(b.path));
for (final file in files) {
final entry = _parseEntryFile(file);
entries[entry.package] = entry;
}
if (overridesFile != null && overridesFile.existsSync()) {
_applyOverrides(entries, overridesFile);
}
return SdkDatabase._(entries);
}