handleIntentExecution method
Executes the registered handler for the given intent.
This method is called internally when an intent execution request is received from iOS, and can also be called directly for testing.
Throws AppIntentError if no handler is registered for the identifier.
Implementation
Future<Map<String, dynamic>> handleIntentExecution(
String identifier,
Map<String, dynamic> params,
) async {
final handler = _intentHandlers[identifier];
if (handler == null) {
throw AppIntentError.fromCode(
AppIntentErrorCode.handlerNotFound,
message: 'No handler registered for intent: $identifier',
details: {'identifier': identifier},
);
}
try {
return await handler(params);
} catch (e) {
if (e is AppIntentError) rethrow;
throw AppIntentError(
code: 'execution_error',
message: 'Error executing intent: $e',
details: {'identifier': identifier, 'error': e.toString()},
);
}
}