instance static method

WalrusFfiBindings instance({
  1. String? libraryPath,
})

Get or create the singleton instance.

libraryPath overrides the default platform-specific library path. If not provided, searches for the library in standard locations. Prefer configure for setting the path before first use.

Implementation

static WalrusFfiBindings instance({String? libraryPath}) {
  if (_instance != null) return _instance!;
  final inst = WalrusFfiBindings._();
  try {
    inst._load(libraryPath ?? _configuredPath);
  } catch (e) {
    // Don't leave a half-initialized singleton — the next call to
    // instance() or isAvailable must retry, not return a broken object.
    _instance = null;
    rethrow;
  }
  _instance = inst;
  return _instance!;
}