StreamMessageAnnotation class

An annotation row for displaying contextual message annotations.

Displays an optional leading widget (typically an icon), a label widget, and an optional trailing widget in a horizontal row. Can be used for various annotation types such as "Saved", "Pinned", "Reminder", etc.

All content is provided by the caller via widget slots. The provided widgets are automatically styled according to StreamMessageAnnotationStyle.

The visual order is always [leading, label, trailing] with configurable spacing between them. Any slot that is null is omitted from the row.

When onTap or onLongPress is provided, the entire row — including its padding — becomes tappable. This gives a forgiving hit target for annotations like "Also sent in channel · View" where the trailing link and the label both lead to the same destination.

When neither is provided, the row is hit-transparent and will not steal taps from widgets beneath it (e.g., in a Stack or overlay). For more targeted behavior (e.g., a tappable trailing link while the rest of the row does nothing), leave onTap/onLongPress null and wrap the trailing widget with its own GestureDetector.

{@tool snippet}

Basic annotation with icon and label:

StreamMessageAnnotation(
  leading: Icon(StreamIcons.bookmark),
  label: Text('Saved'),
)

{@end-tool}

{@tool snippet}

Annotation with a row-level tap and a link-colored trailing label:

StreamMessageAnnotation(
  onTap: () => openChannel(),
  leading: Icon(StreamIcons.arrowUpRight),
  label: Text('Also sent in channel · '),
  trailing: Text('View'),
  style: StreamMessageAnnotationStyle.from(
    trailingTextColor: Theme.of(context).colorScheme.primary,
  ),
)

{@end-tool}

See also:

Inheritance

Constructors

StreamMessageAnnotation({Key? key, Widget? leading, required Widget label, Widget? trailing, VoidCallback? onTap, VoidCallback? onLongPress, StreamMessageAnnotationStyle? style})
Creates a message annotation row.

Properties

hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
props StreamMessageAnnotationProps
The properties that configure this annotation row.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited