AiChatItemPatterns extension

Adds pattern-matching-related methods to AiChatItem.

on

Methods

map<TResult extends Object?>({required TResult user(UserItem value), required TResult assistant(AssistantItem value), required TResult context(ContextItem value), required TResult historySummary(HistorySummaryItem value)}) → TResult

Available on AiChatItem, provided by the AiChatItemPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>({TResult? user(UserItem value)?, TResult? assistant(AssistantItem value)?, TResult? context(ContextItem value)?, TResult? historySummary(HistorySummaryItem value)?}) → TResult?

Available on AiChatItem, provided by the AiChatItemPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>({TResult user(UserItem value)?, TResult assistant(AssistantItem value)?, TResult context(ContextItem value)?, TResult historySummary(HistorySummaryItem value)?, required TResult orElse()}) → TResult

Available on AiChatItem, provided by the AiChatItemPatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>({TResult user(String id, String chatId, String userId, DateTime timestamp, String text)?, TResult assistant(String id, String chatId, String userId, DateTime timestamp, String? modelId, String text)?, TResult context(String id, String chatId, String userId, DateTime timestamp, String text)?, TResult historySummary(String id, String chatId, String userId, DateTime timestampFrom, DateTime timestamp, String? modelId, String text)?, required TResult orElse()}) → TResult

Available on AiChatItem, provided by the AiChatItemPatterns extension

A variant of when that fallback to an orElse callback.
when<TResult extends Object?>({required TResult user(String id, String chatId, String userId, DateTime timestamp, String text), required TResult assistant(String id, String chatId, String userId, DateTime timestamp, String? modelId, String text), required TResult context(String id, String chatId, String userId, DateTime timestamp, String text), required TResult historySummary(String id, String chatId, String userId, DateTime timestampFrom, DateTime timestamp, String? modelId, String text)}) → TResult

Available on AiChatItem, provided by the AiChatItemPatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>({TResult? user(String id, String chatId, String userId, DateTime timestamp, String text)?, TResult? assistant(String id, String chatId, String userId, DateTime timestamp, String? modelId, String text)?, TResult? context(String id, String chatId, String userId, DateTime timestamp, String text)?, TResult? historySummary(String id, String chatId, String userId, DateTime timestampFrom, DateTime timestamp, String? modelId, String text)?}) → TResult?

Available on AiChatItem, provided by the AiChatItemPatterns extension

A variant of when that fallback to returning null