widgets/cl_ai_assistant/flutter_ai_assistant library
Drop-in AI assistant for any Flutter app.
Wrap your MaterialApp with AiAssistant to auto-enable AI capabilities:
AiAssistant(
config: AiAssistantConfig(
provider: GeminiProvider(apiKey: 'your-key'),
),
child: MaterialApp(home: HomeScreen()),
)
Classes
- ActionStep
- A single step shown in the real-time action feed overlay.
- AgentAction
- Record of a single action executed by the AI agent.
- AgentResponse
- Response from the ReAct agent after processing a user message.
- AiActionManifest
- A meaningful action available on a screen.
- AiAppManifest
- Complete hierarchical description of the app for AI navigation.
- AiAssistant
- Drop-in widget that AI-enables any Flutter app.
- AiAssistantConfig
- Configuration for the AI Assistant.
- AiAssistantController
- Controls the AI assistant lifecycle and orchestrates all components.
- AiChatMessage
- A single message in the AI assistant chat conversation.
- AiConversationStore
-
Persistenza conversazioni dell'assistente. Scoped per
scope(es. tenantId) → conversazioni di tenant diversi non si mischiano (isolamento). Pluggable: l'app fornisce un'implementazione via AiAssistantConfig.conversationStore. - AiConversationSummary
- Riassunto di una conversazione salvata (per la lista history).
- AiElementManifest
- A notable UI element the agent should know about.
- AiEvent
- A structured analytics event emitted by the AI Assistant.
- AiFlowManifest
- A multi-step user task that spans multiple screens.
- AiFlowStep
- A single step in a multi-screen flow.
- AiLogger
- Centralized logger for the AI Assistant package.
- An entry in the app's global navigation (bottom nav bar, side menu, etc.).
- Describes a navigation link from one screen to another.
- NavigatorObserver that tracks the full route stack for the AI assistant.
- AiScreenManifest
- Rich description of a single screen in the app.
- AiSectionManifest
- A logical section within a screen (e.g., "Balance Card", "Transaction List").
- AiSuggestionChip
- A suggestion chip shown in the chat overlay's empty state.
- AiTool
- A developer-facing tool that can be registered with the AI assistant. Combines a ToolDefinition with an executable handler function.
- ButtonsContent
- A group of tappable quick-reply buttons.
- CardContent
- A rich card with optional image, title, subtitle, and action buttons.
- ChatButton
- A single tappable button in a chat message.
- ChatContent
- A block of rich content within a chat message.
- CLAiAssistant
- Reusable AI-assistant widget for the Skillera Design System.
- ClaudeProvider
- LLM provider implementation for Anthropic Claude.
- GeminiProvider
- Stub LLM provider for Google Gemini.
- ImageContent
- An inline image content block.
- LlmImageContent
- Binary image data for multimodal LLM messages.
- LlmMessage
- A message in the LLM conversation history.
- LlmProvider
- Abstract interface for LLM providers.
- LlmResponse
- Response from an LLM provider.
- OpenAiProvider
- LLM provider implementation for OpenAI-compatible APIs.
-
Implementazione su
shared_preferences. Una entry JSON per scope:cl_ai_conv:<scope>→ lista di{id, title, updatedAt, messages:[...]}. Tiene al massimo maxConversations conversazioni (le più recenti). - TextContent
- Plain text content block.
- ToolCall
- A structured function call returned by the LLM.
- ToolDefinition
- Definition of a tool that the LLM can call.
- ToolParameter
- A parameter definition for a tool.
- ToolResult
- Result of executing a tool/action.
- VoiceInputService
- Stub per il servizio di input vocale (speech-to-text).
- VoiceOutputService
- Stub per il servizio di output vocale (text-to-speech).
Enums
- ActionStepStatus
- Status of a single step in the agent's action feed.
- AiEventType
- All trackable event types emitted by the AI Assistant.
- AiMessageRole
- Role of a message in the AI chat conversation.
- AiResponseType
- Classification of an AI response for post-task UI behavior.
- ButtonLayout
- Layout options for button groups.
- ChatButtonStyle
- Visual style for chat buttons.
- LlmRole
- Role of a message in the LLM conversation.
Extensions
- AiMessageRoleX on AiMessageRole
- Migration helpers between AiMessageRole and the unified MessageRole.
- LlmRoleX on LlmRole
- Migration helpers between LlmRole and the unified MessageRole.
Functions
-
retryOnRateLimit<
T> (Future< T> action(), {int maxRetries = 2, Duration initialDelay = const Duration(seconds: 2), String tag = 'LLM'}) → Future<T> -
Executes
actionwith up tomaxRetriesretries on RateLimitException. Uses exponential backoff starting atinitialDelay. -
throwForHttpStatus(
int statusCode, String body, String providerName) → Never - Checks an HTTP status code and throws typed exceptions for known errors.
Typedefs
- AiEventCallback = void Function(AiEvent event)
- Callback type for receiving analytics events.
- PostTaskChipsBuilder = ButtonsContent? Function(AgentResponse response)
- Callback type for building post-task follow-up chips.
Exceptions / Errors
- AuthenticationException
- Thrown when the API key is invalid or expired (HTTP 401/403).
- ContentFilteredException
- Thrown when the API rejects the request due to content safety filters.
- ContextOverflowException
- Thrown when the conversation exceeds the model's context window.
- RateLimitException
- Thrown when the API returns a rate-limit response (HTTP 429).