streamResponse method
Sends a message to the chatbot and returns a stream of responses.
Each item in the stream is a Map<String, dynamic>
representing a
structured message part received from the backend (e.g., content, metadata, citations).
Optionally include the threadId
to provide conversation context.
Implementation
Stream<Map<String, dynamic>> streamResponse({
required String message,
String? threadId, // Pass threadId for context
}) {
// Optional: Check initialization status before proceeding
// if (!_isInitialized) {
// return Stream.error(StateError("ChatPlugin not initialized. Call initialize() first."));
// }
return ChatPluginPlatform.instance.streamResponse(
message: message,
threadId: threadId, // Pass threadId to the platform implementation
);
}