SnippetTemplate class
A declarative description of the card Siri shows alongside an intent's result.
App Intents renders these cards with SwiftUI, which a Flutter app has no
way to supply — a Flutter widget tree cannot be handed to Siri. So instead
of taking a view, this takes a small fixed layout (image, title, subtitle,
labelled rows) that the generator turns into a concrete SwiftUI view. It is
deliberately not a general-purpose UI language: anything beyond this shape
belongs in the app itself, reached with openAppWhenRun.
Text fields accept two kinds of placeholder:
{paramName}— an intent parameter, the same syntax asresultDialogTemplate. Works in every execution mode.{result.key}— a key of the map the Dart handler returns. Only available when the intent runs through FlutterBridge, because the URL scheme and cache modes hand off to the app and return before the handler has produced anything. Using one elsewhere is a code generation error.
Example:
@IntentSpec(
identifier: 'com.example.app.createTask',
title: 'Create Task',
resultDialogTemplate: 'Created {title}',
snippet: SnippetTemplate(
title: '{title}',
subtitle: 'Added to {result.listName}',
systemImageName: 'checkmark.circle.fill',
rows: [SnippetRow(label: 'Due', value: '{result.dueDate}')],
),
)
Constructors
-
SnippetTemplate({required String title, String? subtitle, String? systemImageName, List<
SnippetRow> rows = const []}) -
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
rows
→ List<
SnippetRow> -
Labelled rows under the headline, rendered as
LabeledContent.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- subtitle → String?
-
A secondary line under the title. Omitted from the view when null.
final
- systemImageName → String?
-
An SF Symbol shown leading the title (e.g.
'checkmark.circle.fill').final - title → String
-
The card's headline. Required — a card with no title has nothing to say.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited