IntentCallFlutterHost.bindRegistry constructor
IntentCallFlutterHost.bindRegistry({
- required AgentRegistry registry,
- IntentCallAuthorizationPolicy policy = const IntentCallAuthorizationPolicy.denyAll(),
- bool registerWebMcp = false,
- bool drainOnStart = true,
- bool drainOnResume = true,
- bool listenForDeepLinks = false,
- String? protocolScheme,
- IntentCallPendingReader? takePendingInvocations,
- Stream<
IntentCallDrainTrigger> ? wakeSignals, - IntentCallEnvelopeCallback? onEnvelope,
- IntentCallResultCallback? onResult,
- IntentCallResultCallback? onDenied,
- IntentCallErrorCallback? onError,
Implementation
factory IntentCallFlutterHost.bindRegistry({
required final AgentRegistry registry,
final IntentCallAuthorizationPolicy policy =
const IntentCallAuthorizationPolicy.denyAll(),
final bool registerWebMcp = false,
final bool drainOnStart = true,
final bool drainOnResume = true,
final bool listenForDeepLinks = false,
final String? protocolScheme,
final IntentCallPendingReader? takePendingInvocations,
final Stream<IntentCallDrainTrigger>? wakeSignals,
final IntentCallEnvelopeCallback? onEnvelope,
final IntentCallResultCallback? onResult,
final IntentCallResultCallback? onDenied,
final IntentCallErrorCallback? onError,
}) {
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 ??
const IntentCallPendingInvocations().takePending,
registerWebMcp: registerWebMcp,
onEnvelope: onEnvelope,
onResult: onResult,
onDenied: onDenied,
onError: onError,
drainOnStart: drainOnStart,
wakeSignals: wakeSignals ?? lifecycleWakeSignals?.resumeSignals,
lifecycleWakeSignals: lifecycleWakeSignals,
deepLinkListener: deepLinkListener,
);
return host;
}