flutter_ai_elements 0.1.4
flutter_ai_elements: ^0.1.4 copied to clipboard
Composable, themeable Flutter UI for AI chat — conversation, message bubbles, a streaming-aware composer, and a loader — styled entirely through a mobile-first AiThemeExtension. No shadcn/forui dependency.
Changelog #
0.1.4 #
- Internationalization:
AiLocalizations(+AiLocalizationsDelegate) holds the widgets' user-facing strings (defaults English). Every previously-hardcoded tooltip/label/action now reads from it, so apps can translate the UI by providing a delegate.AiConversationList.newChatLabelnow defaults to the localized value.
0.1.3 #
AiConversationList: a ChatGPT-style conversation sidebar (New chat + a list ofChatThreads with select/delete) to pair with aChatThreadStore.
0.1.2 #
- Generative UI:
AiWidgetRegistry(adataType→widget allowlist) andAiDataViewrenderDataParts the model emits as your own widgets — no reflection, unknown types fall back. The demo wires its chain-of-thought / task / confirmation cards through it.
0.1.1 #
AiChatnow anchors the message you just sent to the top of the viewport (ChatGPT-style) and holds it there while the answer streams in below, reserving just enough trailing space and releasing it as the answer grows. A drag releases the pin; a floating "scroll to latest" button appears whenever the conversation is scrolled above the bottom.- New
AiAnimatedResponse: a blur fade-in reveal (the Apple-Intelligence / Siri look) so streamed answers appear smoothly — each newly revealed word arrives blurred and faded, then sharpens into place overfadeDuration(blurSigmacontrols the starting blur). Text is paced at a readablecharsPerSecond(default 120) and accelerates to drain a backlog withincatchUpWindowso it never trails far behind a fast stream. Only the few words at the leading edge animate at once, so the cost stays bounded. The in-flight text renders as plain prose and settles into full Markdown once complete.MarkdownTextRendereruses it automatically while streaming. AiMessageActionsis restyled with compact, evenly spaced icon buttons (ChatGPT-style) and gains optionalonSpeak/onGood/onBad/onShareactions.AiSourcescollapses pastmaxVisiblechips (default 6) behind a "+N more" toggle, so grounded answers that return dozens of sources no longer flood the bubble.- Pluggable syntax highlighting:
AiCodeBlock,AiResponse, andMarkdownTextRendereraccept an optionalCodeHighlighterthat turns code + language into styled spans. The package ships no grammar engine (stays dependency-free); supply one from the app. Defaults to plain monospace. - Fixed the Markdown block parser hanging (and exhausting memory) when handed a
partial stream that ended mid-construct, e.g. a lone
#before its heading text arrived — the parser now always makes forward progress.
0.1.0 #
Initial release.
AiThemeExtension— aThemeExtensionof design tokens (bubble colors, shapes, ambient shadow, spacing, typography, motion, haptics) withcopyWith,lerp,of(context), and a mobile-firstfallback().- Presentational widgets:
AiMessageBubble(renders everyAiParttype; streaming-safe semantics),AiConversationView,AiComposer(Send↔Stop swap, haptics),AiLoader. - Controller-bound widgets:
AiChat(live transcript with auto-scroll and a thinking loader) andAiPromptInput. AiResponse— a dependency-free Markdown renderer (headings, bold/italic, inline + fenced code, lists, blockquotes, links);MarkdownTextRendererwraps it and is now the defaultAiTextRenderer.PlainTextRendererremains.AiChainOfThought(stepwise timeline),AiTask(agent checklist),AiInlineCitation(numbered badge),AiBranch(version navigation),AiImage(loading/error/tap-to-zoom).- Input upgrades:
AiComposergains an attach button, a model-selector slot, a voice button, and removable attachment previews;AiPromptInputstages attachments and switches models via the controller.AiModelSelector,AiConfirmation(approve/deny),AiContextMeter(token usage), andAiShimmer(loading skeleton). AiLiveSession— a full-screen, engine-agnostic Live voice surface (animated orb reacting to amplitude + status, live transcript, mute/keyboard/end). UI only; drive it from a realtime audio engine.- Performance & a11y hardening:
AiResponseparses Markdown and builds gesture recognizers once per text change (not every frame) — important on the streaming hot path;AiLiveSessionanimates only the orb (60fps no longer rebuilds the conversation); message bubbles no longer subscribe to window size in the common bounded case; list items carry stable keys; the composer measures with the ambient text scale + direction; disclosure widgets expose button/expanded semantics; modal sheets scroll; high-traffic layout uses directional insets/alignment for RTL. - Re-exports
flutter_ai_client(andflutter_ai_core).