setResourceProvider method

Future<CommandCompletion> setResourceProvider(
  1. ResourceProvider provider
)

Serves the runtime's network requests through a callback.

The provider receives the network requests that its routes match, and the library loads the rest as usual. A provider can serve URL schemes that the library can't load itself. The provider replaces the one set before.

See mln_runtime_set_resource_provider in the C API reference.

Implementation

Future<CommandCompletion> setResourceProvider(ResourceProvider provider) =>
    _command((arena, completion) {
      final registrations = _NativeRegistrations(_callbackRoots);
      return registrations.run(
        () => raw.mln_runtime_set_resource_provider(
          _handle.raw,
          registrations.add(
            _prepareResourceProvider(provider, registrations.roots),
          ),
          completion,
          nativeDiagnostic,
        ),
      );
    });