create static method

RuntimeHandle create({
  1. RuntimeOptions? options,
})

Creates a runtime.

A runtime holds maps and the resource loading, cache, and offline regions that they share. In a browser, create runtimes on a Web Worker, not on the main thread.

See mln_runtime_create in the C API reference.

Errors:

  • Status.invalidArgument when the cache database file that options names can't be opened or created.

Implementation

static RuntimeHandle create({RuntimeOptions? options}) =>
    withNativeArena((arena) {
      ensureAbiVersion();
      final outRuntime = arena<Uint64>();
      _check(
        raw.mln_runtime_create(
          options == null ? nullptr : _writeRuntimeOptions(options, arena),
          outRuntime,
          nativeDiagnostic,
        ),
      );
      return _adoptOwned(
        outRuntime.value,
        () => RuntimeHandle._(_NativeRuntime(outRuntime.value)),
        (handle) {
          _check(raw.mln_runtime_dispose(handle, nativeDiagnostic));
        },
      );
    });