registerForgeServiceExtensions function

Devtools? registerForgeServiceExtensions(
  1. QueryCache cache, {
  2. RestTransport? transport,
  3. ControlledTransport? controls,
  4. Map<String, OperationMeta> operations = const {},
  5. OutboxInspector? outbox,
  6. Revalidation? revalidation,
})

Attaches the devtools to cache and exposes it to Flutter DevTools.

configureClient calls this in debug and profile builds. Call it yourself for a cache you built with the QueryCache constructor. transport feeds the request log through its debug observer slot; controls is the offline and latency simulator wrapped around the cache's transport; operations is the generated operations table, which lets the panel preview any operation; outbox lets the panel replay and discard.

On a cache that is already attached (every configureClient cache in a debug build), a later call registers nothing again and needs no unregister first. It sets outbox on the existing devtools when one is given, and fills what is still empty: transport when no request log is wired, controls and revalidation when none is, and operations by id. A slot that is filled is never overwritten, so the first registration wins.

Throws a StateError for a disposed cache. Returns null, and does nothing, when kForgeDevtools is false.

Implementation

dt.Devtools? registerForgeServiceExtensions(
  QueryCache cache, {
  RestTransport? transport,
  ControlledTransport? controls,
  Map<String, OperationMeta> operations = const {},
  OutboxInspector? outbox,
  Revalidation? revalidation,
}) {
  if (!kForgeDevtools) return null;
  return ForgeDevtoolsHost.instance.attach(
    cache,
    transport: transport,
    controls: controls,
    operations: operations,
    outbox: outbox,
    revalidation: revalidation,
  );
}