IntentCallFlutterHost.bindRegistry constructor

IntentCallFlutterHost.bindRegistry({
  1. required AgentRegistry registry,
  2. IntentCallAuthorizationPolicy policy = const IntentCallAuthorizationPolicy.denyAll(),
  3. bool registerWebMcp = false,
  4. ManifestSurfaceIndex? webMcpSurfaceIndex,
  5. bool drainOnStart = true,
  6. bool drainOnResume = true,
  7. bool listenForDeepLinks = false,
  8. String? protocolScheme,
  9. IntentCallPendingReader? takePendingInvocations,
  10. IntentCallEntityOpenReader? takePendingEntityOpens,
  11. Stream<IntentCallDrainTrigger>? wakeSignals,
  12. IntentCallEnvelopeCallback? onEnvelope,
  13. IntentCallResultCallback? onResult,
  14. IntentCallResultCallback? onDenied,
  15. IntentCallErrorCallback? onError,
  16. IntentCallEntityOpenCallback? onEntityOpen,
  17. bool publishSurfaceLink = false,
  18. String? linkDirectory,
})

Implementation

factory IntentCallFlutterHost.bindRegistry({
  required final AgentRegistry registry,
  final IntentCallAuthorizationPolicy policy =
      const IntentCallAuthorizationPolicy.denyAll(),
  final bool registerWebMcp = false,
  final ManifestSurfaceIndex? webMcpSurfaceIndex,
  final bool drainOnStart = true,
  final bool drainOnResume = true,
  final bool listenForDeepLinks = false,
  final String? protocolScheme,
  final IntentCallPendingReader? takePendingInvocations,
  final IntentCallEntityOpenReader? takePendingEntityOpens,
  final Stream<IntentCallDrainTrigger>? wakeSignals,
  final IntentCallEnvelopeCallback? onEnvelope,
  final IntentCallResultCallback? onResult,
  final IntentCallResultCallback? onDenied,
  final IntentCallErrorCallback? onError,
  final IntentCallEntityOpenCallback? onEntityOpen,
  final bool publishSurfaceLink = false,
  final String? linkDirectory,
}) {
  final lifecycleWakeSignals = wakeSignals == null && drainOnResume
      ? IntentCallLifecycleWakeSignals()
      : null;
  late final IntentCallFlutterHost host;
  final deepLinkListener = listenForDeepLinks
      ? IntentCallInvokeLinkListener(
          protocolScheme: _requireProtocolScheme(protocolScheme),
          onQualifiedName: (_) {
            unawaited(
              host
                  .requestDrain(IntentCallDrainTrigger.deepLink)
                  .catchError((_) => <AgentResult>[]),
            );
          },
        )
      : null;
  // The deep-link callback captures the host, so this cannot be inlined.
  // ignore: join_return_with_assignment
  host = IntentCallFlutterHost._(
    bridge: IntentCallNativeBridge.bindRegistry(
      registry: registry,
      policy: policy,
    ),
    takePendingInvocations:
        takePendingInvocations ??
        // ignore: prefer_const_constructors
        IntentCallPendingInvocations().takePending,
    takePendingEntityOpens:
        takePendingEntityOpens ??
        // ignore: prefer_const_constructors
        IntentCallPendingEntityOpens().takePending,
    registerWebMcp: registerWebMcp,
    webMcpSurfaceIndex: webMcpSurfaceIndex,
    onEnvelope: onEnvelope,
    onResult: onResult,
    onDenied: onDenied,
    onError: onError,
    onEntityOpen: onEntityOpen,
    drainOnStart: drainOnStart,
    wakeSignals: wakeSignals ?? lifecycleWakeSignals?.resumeSignals,
    lifecycleWakeSignals: lifecycleWakeSignals,
    deepLinkListener: deepLinkListener,
    publishSurfaceLink: publishSurfaceLink,
    protocolScheme: protocolScheme,
    linkDirectory: linkDirectory,
  );
  return host;
}