RichComponent class sealed

Base sealed class for all rich content components.

Available extensions
Annotations
  • @Freezed.new(unionKey: 'type')

Constructors

RichComponent.buttonGroup({required String id, required List<RichButton> buttons, @Default.new('horizontal') String layout})
Button group component for action buttons
const
factory
RichComponent.card({required String id, required String title, RichImage? image, String? subtitle, String? description, @JsonKey.new(fromJson: _metadataFromJson) Map<String, String>? metadata, List<RichAction>? actions})
Card component with image, title, description, and actions
const
factory
RichComponent.carousel({required String id, required List<RichComponent> items, CarouselConfig? config})
Carousel component for horizontal scrolling items
const
factory
RichComponent.fromJson(Map<String, dynamic> json)
factory
RichComponent.hostSlot({required String id, @JsonKey.new(name: 'slot_id') required String slotId, Map<String, dynamic>? payload})
A slot the host app fills with its OWN native widget. The bot reserves a spot in the bubble and names a slotId; the host registers a HostSlotBuilder on ChatWidget that turns (slotId, payload) into a Flutter widget. Use it for app-owned inline UI the server can't draw — e.g. a live PDF preview of a generated document, or a design picker showing real template thumbnails.
const
factory
RichComponent.image({required String id, required String url, String? alt, String? caption, @JsonKey.new(name: 'aspect_ratio') String? aspectRatio, List<RichAction>? actions, @JsonKey.new(name: 'on_tap_callback') OnTapCallback? onTapCallback})
Standalone image component
const
factory
RichComponent.productList({required String id, required List<RichComponent> items, ProductListConfig? config})
Product list component for vertical or grid layouts
const
factory
RichComponent.swatchGrid({required String id, required List<RichSwatch> swatches, @Default.new(4) int columns})
Grid of color swatches the user can tap to send a message or trigger a callback. Designed for the "pick a vibe / pick a color" inline UX where labeled text buttons feel clinical: real circles with hex fills communicate the look-and-feel at a glance.
const
factory
RichComponent.text({required String content, @Default.new('markdown') String format})
Text component for markdown or plain text
const
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

map<TResult extends Object?>({required TResult text(TextComponent value), required TResult card(CardComponent value), required TResult carousel(CarouselComponent value), required TResult productList(ProductListComponent value), required TResult image(ImageComponent value), required TResult buttonGroup(ButtonGroupComponent value), required TResult swatchGrid(SwatchGridComponent value), required TResult hostSlot(HostSlotComponent value)}) → TResult

Available on RichComponent, provided by the RichComponentPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>({TResult? text(TextComponent value)?, TResult? card(CardComponent value)?, TResult? carousel(CarouselComponent value)?, TResult? productList(ProductListComponent value)?, TResult? image(ImageComponent value)?, TResult? buttonGroup(ButtonGroupComponent value)?, TResult? swatchGrid(SwatchGridComponent value)?, TResult? hostSlot(HostSlotComponent value)?}) → TResult?

Available on RichComponent, provided by the RichComponentPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>({TResult text(TextComponent value)?, TResult card(CardComponent value)?, TResult carousel(CarouselComponent value)?, TResult productList(ProductListComponent value)?, TResult image(ImageComponent value)?, TResult buttonGroup(ButtonGroupComponent value)?, TResult swatchGrid(SwatchGridComponent value)?, TResult hostSlot(HostSlotComponent value)?, required TResult orElse()}) → TResult

Available on RichComponent, provided by the RichComponentPatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>({TResult text(String content, String format)?, TResult card(String id, String title, RichImage? image, String? subtitle, String? description, Map<String, String>? metadata, List<RichAction>? actions)?, TResult carousel(String id, List<RichComponent> items, CarouselConfig? config)?, TResult productList(String id, List<RichComponent> items, ProductListConfig? config)?, TResult image(String id, String url, String? alt, String? caption, String? aspectRatio, List<RichAction>? actions, OnTapCallback? onTapCallback)?, TResult buttonGroup(String id, List<RichButton> buttons, String layout)?, TResult swatchGrid(String id, List<RichSwatch> swatches, int columns)?, TResult hostSlot(String id, String slotId, Map<String, dynamic>? payload)?, required TResult orElse()}) → TResult

Available on RichComponent, provided by the RichComponentPatterns extension

A variant of when that fallback to an orElse callback.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes this RichComponent to a JSON map.
inherited
toString() String
A string representation of this object.
inherited
when<TResult extends Object?>({required TResult text(String content, String format), required TResult card(String id, String title, RichImage? image, String? subtitle, String? description, Map<String, String>? metadata, List<RichAction>? actions), required TResult carousel(String id, List<RichComponent> items, CarouselConfig? config), required TResult productList(String id, List<RichComponent> items, ProductListConfig? config), required TResult image(String id, String url, String? alt, String? caption, String? aspectRatio, List<RichAction>? actions, OnTapCallback? onTapCallback), required TResult buttonGroup(String id, List<RichButton> buttons, String layout), required TResult swatchGrid(String id, List<RichSwatch> swatches, int columns), required TResult hostSlot(String id, String slotId, Map<String, dynamic>? payload)}) → TResult

Available on RichComponent, provided by the RichComponentPatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>({TResult? text(String content, String format)?, TResult? card(String id, String title, RichImage? image, String? subtitle, String? description, Map<String, String>? metadata, List<RichAction>? actions)?, TResult? carousel(String id, List<RichComponent> items, CarouselConfig? config)?, TResult? productList(String id, List<RichComponent> items, ProductListConfig? config)?, TResult? image(String id, String url, String? alt, String? caption, String? aspectRatio, List<RichAction>? actions, OnTapCallback? onTapCallback)?, TResult? buttonGroup(String id, List<RichButton> buttons, String layout)?, TResult? swatchGrid(String id, List<RichSwatch> swatches, int columns)?, TResult? hostSlot(String id, String slotId, Map<String, dynamic>? payload)?}) → TResult?

Available on RichComponent, provided by the RichComponentPatterns extension

A variant of when that fallback to returning null

Operators

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