prism library
Prism — a unified Flutter component library.
Adaptive, Material-style widgets that feel native on phone, desktop and web. Part of the Prism package family, consolidated into a single package.
Classes
- AdaptiveDestination
- A navigation destination for PrismAdaptiveScaffold.
- AdaptiveDialogAction
- Pre-styled action buttons for PrismAdaptiveDialog.show.
- AiAgent
- Runs an automatic tool-calling loop on top of any AiStreamClient.
- AiAgentResult
- The result of an AiAgent.run call.
- AiChatController
-
A ready-made streaming chat UI built on the
prism_aievent model. - AiChatMessage
- A single message in a chat conversation.
- AiChatView
- Renders a chat conversation with streaming assistant responses.
- AiDone
- The completion finished normally.
- AiError
- The stream failed. The error is provider-agnostic.
- AiStreamClient
-
Common interface for all provider adapters in
prism_ai. - AiTextDelta
- A chunk of assistant text has arrived.
- AiTool
- A tool the model can invoke — the unit of AI agency.
- AiToolCall
- The model invoked a tool.
- AiToolCallRequest
- A tool invocation declared by the assistant (OpenAI protocol shape).
- AiUsage
- Token usage reported by the provider, when available.
- AnthropicStreamClient
-
Streams chat completions from the Anthropic Messages API
(
https://api.anthropic.com/v1/messages). - AsyncPrefsBackend
-
SkipStoreBackend over
SharedPreferencesAsync. - BannerDismissStore
- Persists which announcements (and versions) the user has dismissed.
- ChangelogEntry
- A semantic changelog entry: one release version and its change bullets.
- ChangelogParser
- Parses Keep-a-Changelog-style markdown into ChangelogEntrys.
- ChangelogStyle
- Visual configuration for ChangelogView and WhatsNewSheet.
- ChangelogView
- Renders parsed ChangelogEntrys as beautiful version cards.
- CodeToken
- A single span of source code and its syntactic kind.
- Color
- An immutable color value in ARGB format.
- ColorPalette
- A palette extracted from a source image: a ranked list of dominant colors plus the six classic Android-Palette swatches (vibrant, muted, and their light/dark variants).
- DartTokenizer
- Tokenizer for Dart source code.
- EmbeddingsClient
-
Text embeddings from any OpenAI-compatible
/embeddingsendpoint (OpenAI, Ollama, Groq, DeepSeek, Together, LM Studio, vLLM). - FetchFailure
- The outcome of a failed fetch attempt.
- FetchInstructions
- The verdict of a FetchStrategy: wait waitFor, then retry.
- FetchStrategyBuilder
- Builds common retry strategies: exponential backoff with optional jitter, bounded by attempt count, with a pluggable predicate for which HTTP status codes count as transient.
- GeminiStreamClient
-
Streams chat completions from the Google Gemini API
(
streamGenerateContent?alt=sse). - HSV
- Hue/saturation/value triple.
- InMemoryDismissStore
- In-memory store for tests and previews.
- InMemorySeenStore
- In-memory store for tests and previews.
- JsonTokenizer
- Tokenizer for JSON documents.
- LanguageTokenizer
- Strategy for splitting source code into CodeTokens.
- MemoryBackend
- In-memory SkipStoreBackend for tests.
- NetworkImageWithRetry
- An ImageProvider that fetches the image at url over the network and retries transient failures according to a fetchStrategy.
- OpenAiStreamClient
- Streams chat completions from any OpenAI-compatible endpoint.
- PaletteExtractor
- Extracts a ColorPalette from raw ARGB pixel data.
- PaletteSwatch
- A color selected from a palette, together with how prominently it appeared in the source image.
- PaletteTarget
- Describes one of the six classic palette swatch targets.
- PaletteWeights
- The weights used when scoring a candidate color against a target.
- PrismAccordion
- A stack of collapsible sections.
- PrismAccordionSection
- One collapsible section of a PrismAccordion.
- PrismActionTile
- Tile that navigates or performs an action on tap.
- PrismAdaptiveDialog
- Shows adaptive dialogs: a modal bottom sheet on phones, a centered dialog on tablets and desktops — from a single call.
- PrismAdaptiveScaffold
- A responsive scaffold that adapts its navigation to the window class.
- PrismAdaptiveSheet
- Shows a surface that adapts to the window: a bottom sheet on compact windows, a centred dialog on wide ones.
- PrismAgentRunner
- Runs an AI agent loop that persists messages across calls.
- PrismAiMessageBubble
- One conversation turn as a token-styled chat bubble.
- PrismAiThinkingIndicator
- Animated indicator shown while an assistant is producing a reply.
- PrismAnnouncement
- An in-app announcement shown by PrismBanner.
- PrismAvatar
- A circular or rounded avatar with initials fallback, presence and status.
- PrismBadge
- A small count or status pill that sits on top of another widget.
- PrismBanner
- Renders the first active, not-yet-dismissed PrismAnnouncement as a dismissible banner above your content.
- PrismBannerStyle
- Visual configuration for PrismBanner.
- PrismBreakpoint
- A set of well-known width thresholds that map screen sizes to semantic window classes.
- PrismCalendar
- A month-grid calendar with optional range and multi-day selection.
- PrismCard
- A card with an optional tap target, corner radius and elevation from tokens.
- PrismCarousel
- A simple carousel that shows a horizontally scrolling list of widgets, with a page indicator underneath.
-
PrismChainStep<
T extends Object> - A single step in a PrismPromptChain.
- PrismCheckbox
- A checkbox with a title and semantics, in the same shape as PrismSwitch.
- PrismCheckboxField
- Boolean checkbox field.
- PrismCheckboxTile
- Checkbox tile variant.
- PrismChipInput
- A free-form tag/chip input: type, press Enter or comma, get a chip.
- PrismCircularProgress
- A circular progress indicator with a value in the middle.
- PrismCodeView
- A syntax-highlighted, copyable code viewer widget.
- PrismCodeViewStyle
- Visual configuration for PrismCodeView.
- PrismColorPicker
- A compact HSV colour picker with hue/saturation/value drag surfaces and a hex text field.
- PrismColors
- Semantic colors derived from the active ColorScheme.
-
PrismColumn<
T> - One column of a PrismDataTable.
- PrismCommand
- One command shown in a PrismCommandPalette.
- PrismCommandPalette
- A ⌘K-style command palette that can be opened from anywhere.
- PrismConnectionBanner
- A slim banner that appears while the app is offline and disappears the moment connectivity returns.
- PrismContextBudget
- Keeps a conversation inside a model's context window.
-
PrismDataTable<
T> - A data table that becomes a card list on narrow windows.
- PrismDebugOverlay
- A live inspector for the Prism design system.
- PrismDivider
- A hairline divider with optional label, for grouping content.
- PrismDividerWithLabel
- A divider with a label centred in it, for grouping content.
- PrismDownloadCancelled
- Terminal event: download was cancelled by the caller.
- PrismDownloadComplete
- Terminal event: download completed; file points at the saved artifact.
- PrismDownloadEvent
- Events emitted while a download is running.
- PrismDownloadFailed
- Terminal event: download failed.
- PrismDownloadManager
- Streams a file to disk with progress reporting and cancellation.
- PrismDownloadProgress
- Progress snapshot for a running download.
- PrismDownloadScreen
- Full-screen page with a live progress bar while a direct download runs.
-
PrismDropdown<
T> - A dropdown field with a label, an optional icon, and validation.
-
PrismDropdownField<
T> - Dropdown selection field.
-
PrismDropdownItem<
T> - One option in a PrismDropdown.
-
PrismDropdownTile<
T> - Dropdown selection tile.
- PrismEmptyState
- A friendly empty state with an icon, a title, a subtitle and an action.
- PrismFabAction
- One action in a PrismFabMenu.
- PrismFabMenu
- A floating action button that expands into a menu of actions.
- PrismFieldCommon
- Base configuration shared by all fields.
- PrismForceUpdateScreen
- Full-screen page shown when an update is required.
- PrismForm
- Declarative form container.
- PrismFormController
- Headless form state manager.
- PrismFormEditing
- The user has edited at least one field.
- PrismFormFailure
- The last submission failed.
- PrismFormPristine
- The form has not been edited yet.
- PrismFormScope
- Provides the active PrismFormController to field widgets via an InheritedNotifier; dependents rebuild on every controller change.
- PrismFormStatus
- Sealed lifecycle of a form submission.
- PrismFormSubmitting
- A submission is in flight.
- PrismFormSuccess
- The last submission succeeded.
- PrismGuard
- Validates AI responses before showing them to the user.
- PrismLinearProgress
- A determinate or indeterminate linear progress bar with Prism tokens.
- PrismLoadingOverlay
- A full-screen or scoped overlay that blocks interaction while loading.
- PrismLottie
- Parses a Lottie JSON file and reports the metadata needed to size and play it.
- PrismLottieCache
- Preloads Lottie animations from an asset directory.
- PrismMarkdown
- A widget that renders markdown text as rich, selectable Flutter UI.
- PrismMarkdownStyle
- Visual configuration for PrismMarkdown widgets.
-
PrismMasterDetail<
T> - An adaptive master-detail layout.
- PrismMessageMemory
- Conversation memory that trims old turns and can summarise them.
- PrismOtpField
- A one-time-code / PIN field with paste, auto-submit and SMS autofill.
- PrismOverlayStack
- A guided onboarding tour that dims the screen and spotlights widgets.
- PrismOverlayStep
- A step in a PrismOverlayStack onboarding tour.
-
PrismPaginatedList<
T> - Infinite-scroll list with built-in pagination states.
- PrismPasswordField
- Password field with visibility toggle.
- PrismPromptChain
- Runs a sequence of prompts where each step's output feeds the next.
- PrismPromptComposer
- An input row for prompting an AI assistant.
- PrismRateLimiter
- A token-bucket rate limiter for AI API calls.
- PrismRating
- A star rating that is operable without sight and without a mouse.
- PrismRefreshIndicator
-
A pull-to-refresh wrapper that works with any scrollable child, not just
ListView. - PrismResponseCache
- Caches AI responses by prompt hash so repeated calls don't re-bill.
- PrismScrollTrigger
- Reports when the attached scroll view approaches its end, so the list can trigger the next page load before the user reaches the bottom.
-
PrismSearch<
T> - An adaptive search widget.
- PrismSearchHighlightStyle
- How matched text is emphasized inside suggestion rows.
-
PrismSegment<
T> - One option in a PrismSegmentedControl.
-
PrismSegmentedControl<
T> - A single-choice segmented control that stays usable on a phone.
- PrismSettingsController
- Change-notifying value store for settings tiles.
- PrismSettingsPage
- A ready-made settings page.
- PrismSettingsScope
- Scope exposing the active PrismSettingsController to tiles.
- PrismSettingsSection
- A titled group of tiles with rounded card styling.
-
PrismSheetAction<
T> - A labelled button at the bottom of a PrismAdaptiveSheet.
- PrismSkeleton
- A shimmering placeholder shown while content loads.
- PrismSkeletonCard
- A card-shaped skeleton: media block plus body copy.
- PrismSkeletonList
- A vertical list of count skeletons — the standard "list is loading" state.
- PrismSkeletonText
- A paragraph-shaped skeleton — several lines with a shorter last line.
- PrismSkipStore
-
Remembers which versions the user has skipped or dismissed, and whether
an update screen was seen, using
SharedPreferences. - PrismSlider
- A slider styled with Prism tokens and accessible to screen readers.
- PrismSliderTile
-
Slider tile for numeric values in
min, max. - PrismSoftUpdateCard
- Compact dismissible card for optional updates.
- PrismSparkline
- A tiny inline trend line for lists, tables and stat cards.
-
PrismStateView<
T> - Renders one widget for all four async UI states: loading, error, empty, and success — with built-in retry and smart defaults.
- PrismStateViewStyle
- Visual configuration for PrismStateView.
- PrismStep
- One step of a PrismStepper.
- PrismStepper
- A horizontal progress stepper for wizards and multi-step flows.
- PrismStructuredOutput
- Pulling structured data out of a language model's reply.
- PrismSwitch
- A switch with a semantics label and a Prism colour scheme.
- PrismSwitchTile
- Switch tile bound to the controller by PrismTileCommon.key.
- PrismSyncSnapshot
- An immutable snapshot of a sync engine's state.
- PrismSyncStatus
- A compact, always-on-screen indicator of sync state.
- PrismTab
- One tab in a PrismTabs.
- PrismTabs
- Tabs that adapt to the window instead of overflowing.
- PrismTextField
- Single-line text field with type presets.
- PrismTile
- A list tile with a leading icon, title, subtitle, trailing widget and an optional badge, using Prism tokens for the spacing.
- PrismTileCommon
- Shared tile configuration.
- PrismTimeline
- A vertical timeline of events, with connectors drawn between markers.
- PrismTimelineEntry
- One event on a PrismTimeline.
- PrismToast
- Adaptive, beautiful toast notifications.
- PrismToastMessage
- One toast shown by PrismToast.show.
- PrismTokens
- The shared design tokens every Prism component reads from.
- PrismUpdateAvailable
- An update is available (soft or forced per the policy).
- PrismUpdateChecking
- A check is in flight.
- PrismUpdateController
- Headless controller that checks versions and exposes an update state.
- PrismUpdateFailure
- The check failed.
- PrismUpdateGate
- Widget that listens to a PrismUpdateController and renders the right update experience over child.
- PrismUpdateIdle
- No check has run yet.
- PrismUpdatePlatformInfo
- Information about the platform the app is running on, used to pick the right update flow per platform.
- PrismUpdateProgress
- Small inline widget showing an update-in-progress status.
- PrismUpdateSkipped
- The check ran, but the available soft update was previously skipped.
- PrismUpdateSource
- Where release metadata comes from.
- PrismUpdateState
- Sealed states emitted by PrismUpdateController.
- PrismUpdateStatusView
- Read-only summary widget of any controller state, useful for debug pages.
- PrismUpdateUpToDate
- The installed version satisfies the policy.
- PrismVersion
- A parsed version value with component-wise comparison.
-
PrismViewEmpty<
T> - Success-with-no-data state.
-
PrismViewError<
T> - Failure state.
-
PrismViewLoading<
T> - In-progress state.
-
PrismViewState<
T> - A sealed view-state that drives PrismStateView rendering.
-
PrismViewStateNotifier<
T> - Converts a Future into a ValueNotifier of PrismViewStates, for apps not using a state-management package.
-
PrismViewSuccess<
T> - Success state carrying data.
- PrismZoomableImage
- An image with pinch-to-zoom and pan, plus double-tap to reset.
- Rect
- An immutable, 2D, axis-aligned, floating-point rectangle whose coordinates are relative to a given origin.
- RemoteUpdateSource
- Fetches release metadata from an HTTP endpoint returning JSON such as:
- SeenVersionStore
- Persists the newest changelog version the user has seen, powering "What's New" detection.
-
SharedPreferences-backed store used by default. -
SharedPreferences-backed store used by default. - SkipStoreBackend
- Backing store abstraction so tests can inject an in-memory implementation.
- SseEvent
- A single parsed SSE event.
- SseParser
- Stateful incremental parser: feed it raw string chunks, receive fully assembled SseEvents.
- StaticUpdateSource
- A source backed by a fixed map. Useful for tests, demos, and kill switches where you want to ship a version bump without a server.
- StoreFlowLauncher
- Opens native store flows for updates:
- StreamingJsonParser
- Parses partial JSON output from a streaming AI response.
- UpdatePolicy
- Decides whether the running app should update.
- UpdatePolicyResult
- The result of evaluating an update policy.
- Validators
- Commonly used PrismValidators, composable via Validators.all.
- WhatsNewSheet
- A ready-made "What's New" bottom sheet.
- YamlTokenizer
- Tokenizer for YAML documents.
Enums
- AiRole
- The role of a message in a conversation.
- GateBehavior
- How the gate behaves when an update is available.
- PresentationStyle
- How a dialog should be presented on a given window class.
- PrismAvatarShape
- The shape of a PrismAvatar.
- PrismBannerPriority
- Selection order when multiple announcements are eligible.
- PrismCompactBehavior
- How the detail pane is presented on compact (phone-width) windows.
- PrismDateSelection
- Which days a PrismCalendar lets the user pick.
- PrismDensity
- How tightly a Prism app is spaced.
- PrismLanguage
- Picker for the built-in tokenizers.
- PrismMotion
- How quickly motion runs.
- PrismPresence
- Online/away/busy/offline presence indicator.
- PrismSemantic
- The semantic roles Prism components speak in.
- PrismSeverity
- Visual severity levels for PrismAnnouncement.
- PrismShape
- The corner-radius personality of a Prism app.
- PrismSkeletonListKind
- Which skeleton layout PrismSkeletonList renders.
- PrismSkeletonShape
- The shape of a PrismSkeleton.
- PrismStepState
- The state of a single step in a PrismStepper.
- PrismSyncPhase
- The state of a background synchronisation, as PrismSyncStatus needs it.
- PrismToastType
- The visual/semantic type of a toast.
- StoreLaunchResult
- How the native store flow launched.
- TokenKind
- The kind of a syntactic element found in source code.
- UpdateChannel
- Update channel a release belongs to.
- UpdateDecision
- What the policy decided the app should do.
Extensions
- PrismMotionContext on BuildContext
- Motion that respects the user's accessibility settings.
- PrismTokenContext on BuildContext
- Convenience access to PrismTokens straight from a BuildContext.
- PrismTokenPresets on PrismTokens
- Builds a token set from a density, a shape and a motion preference.
Constants
-
kDefaultTransientHttpStatusCodes
→ const Set<
int> -
The status codes the original
flutter_imagetreated as transient.
Functions
-
buildInlineSpans(
List< Node> nodes, PrismMarkdownStyle style, {void onLinkTap(String href)?}) → InlineSpan - Exposed for advanced use: builds inline spans directly.
-
cosineSimilarity(
List< double> a, List<double> b) → double - Computes cosine similarity between two vectors (0.0 = orthogonal, 1.0 = identical direction). Standard RAG similarity metric.
-
defaultTransientHttpStatusCodePredicate(
int statusCode) → bool - Default predicate: the classic transient status-code set.
-
highlightQuery(
String label, String query, TextStyle baseStyle, PrismSearchHighlightStyle? highlightStyle) → TextSpan -
Splits
labelinto plain/highlighted segments around every case-insensitive occurrence ofquery. -
prismTheme(
{Color seed = const Color(0xFF39A9DB), Brightness brightness = Brightness.light, PrismDensity density = PrismDensity.comfortable, PrismShape shape = PrismShape.rounded, PrismMotion motion = PrismMotion.standard, PrismTokens? tokens, ThemeData? base}) → ThemeData - Builds a fully configured ThemeData for a Prism app.
-
pseudoRandom(
) → double - Deterministic lightweight jitter source: keeps test runs reproducible without pulling dart:math Random seeding on every call.
-
scoreCandidate(
{required Hct candidate, required double population, required double maxPopulation, required PaletteTarget target, PaletteWeights weights = const PaletteWeights()}) → double - Scores a single candidate against a PaletteTarget.
Typedefs
-
FetchStrategy
= Future<
FetchInstructions?> Function(Uri uri, FetchFailure? failure) - Decides whether and when to retry a failed fetch.
-
PrismConnectionSource
= Stream<
bool> Function() - How a PrismConnectionBanner learns about connectivity.
- PrismValidator = String? Function(String? value)
- A single validation rule for a PrismFormController field.
- TransientHttpStatusCodePredicate = bool Function(int statusCode)
- Predicate over HTTP status codes that returns true for codes worth retrying. The default matches the classic transient set.
Exceptions / Errors
- EmbeddingsException
- Thrown when the embeddings request fails.
- NetworkImageRetryException
- Thrown when all retry attempts are exhausted.
- PrismSubmissionException
- Thrown from a submit handler to surface per-field errors after a server-side rejection (e.g. "email already taken").
- PrismVersionException
- Thrown when a version string cannot be parsed.