RichComponentPatterns extension

Adds pattern-matching-related methods to RichComponent.

on

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.
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