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, RichImage? image, required String title, 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.image({required String id, required String url, String? alt, String? caption, @JsonKey.new(name: 'aspect_ratio') String? aspectRatio, List<RichAction>? actions})
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.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)}) → 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?

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)?, 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, RichImage? image, String title, 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)?, TResult buttonGroup(String id, List<RichButton> buttons, String layout)?, 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, RichImage? image, String title, 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), required TResult buttonGroup(String id, List<RichButton> buttons, String layout)}) → 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, RichImage? image, String title, 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)?, TResult? buttonGroup(String id, List<RichButton> buttons, String layout)?}) → 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