RichComponent class sealed
Base sealed class for all rich content components.
- Available extensions
- Annotations
-
- @Freezed.new(unionKey: 'type')
Constructors
-
Button group component for action buttons
constfactory
-
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
constfactory
-
RichComponent.carousel({required String id, required List<
RichComponent> items, CarouselConfig? config}) -
Carousel component for horizontal scrolling items
constfactory
-
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 aHostSlotBuilderon 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.constfactory -
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
constfactory
-
RichComponent.productList({required String id, required List<
RichComponent> items, ProductListConfig? config}) -
Product list component for vertical or grid layouts
constfactory
-
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.
constfactory
- RichComponent.text({required String content, @Default.new('markdown') String format})
-
Text component for markdown or plain text
constfactory
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
Aswitch-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 ofmapthat fallback to returningnull. -
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 ofmapthat fallback to returningorElse. -
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 ofwhenthat fallback to anorElsecallback. -
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
Aswitch-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 ofwhenthat fallback to returningnull
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited