findRaylib function
Locates the native raylib library by walking up from the current
working directory until a directory named folder is found.
For each RaylibSupportedLibs entry, resolves the platform-specific library file inside that directory and returns a bound Raylib instance wrapping all of them.
Set silent to suppress Raylib's init/dispose log output.
Throws an Exception if folder can't be found before reaching the
filesystem root, or if the current platform isn't supported.
Implementation
Raylib findRaylib(String folder, { bool silent = false }) {
var dir = Directory.current;
while (true) {
final raylibPath = path.join(dir.path, folder);
if (Directory(raylibPath).existsSync()) {
final Map<RaylibSupportedLibs, String?> libs = {};
for (final lib in RaylibSupportedLibs.values) {
libs[lib] = _platformLibPath(raylibPath, lib.id);
}
return Raylib(libs: libs, silent: silent);
}
final parent = dir.parent;
if (parent.path == dir.path) throw Exception('Could not find $folder directory');
dir = parent;
}
}