load static method
Loads a dynamic library from the specified modulePath
and returns
an FfiWrapper instance encapsulating the library.
If the module is statically linked on Android or iOS, it returns a reference to the current process's dynamic library.
modulePath
: The path to the module to be loaded.
overrides
: AppType specific overrides to the path to the module to be loaded.
Returns a Future that completes with an FfiWrapper instance. Throws an ArgumentError if the module cannot be found.
Implementation
static Future<FfiWrapper> load(
String modulePath, {
Map<AppType, String> overrides = const {},
}) async {
final resolvedModulePath =
overrides[appType] ?? resolveModulePath(modulePath);
// Handle statically linked modules for Android/iOS
if (resolvedModulePath.isEmpty) {
return FfiWrapper._(DynamicLibrary.process());
}
return FfiWrapper._(
await DynamicLibrary.open(resolvedModulePath),
);
}