invokeIntent method
Invokes an intent the way the system does, through the installed dispatcher.
Returns the wire map the native side would receive: {'kind': 'dialog', 'spoken': …} for a spoken answer, {'kind': 'failure', 'message': …}
for an IntentResult.failure, {'kind': 'error', …} for a handler that
threw.
Implementation
Future<Map<String, Object?>> invokeIntent(
String id, {
Map<String, Object?> args = const {},
bool background = false,
}) {
final handler = background ? _backgroundInvocations : _invocations;
if (handler == null) {
throw StateError(
'No invocation handler installed. Call OsIntents.install() '
'${background ? '(or installBackground) ' : ''}first.',
);
}
return handler(id, args);
}