ToolResultPatterns extension

Adds pattern-matching-related methods to ToolResult.

on

Methods

map<TResult extends Object?>({required TResult response(_ToolResponse value), required TResult error(_ToolError value)}) → TResult

Available on ToolResult, provided by the ToolResultPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>({TResult? response(_ToolResponse value)?, TResult? error(_ToolError value)?}) → TResult?

Available on ToolResult, provided by the ToolResultPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>({TResult response(_ToolResponse value)?, TResult error(_ToolError value)?, required TResult orElse()}) → TResult

Available on ToolResult, provided by the ToolResultPatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>({TResult response(String content, String toolCallId, String? customSessionId, String? toolName, String? toolType)?, TResult error(String error, String toolCallId, String? code, String? content, String? customSessionId, String? level, String? toolType)?, required TResult orElse()}) → TResult

Available on ToolResult, provided by the ToolResultPatterns extension

A variant of when that fallback to an orElse callback.
when<TResult extends Object?>({required TResult response(String content, String toolCallId, String? customSessionId, String? toolName, String? toolType), required TResult error(String error, String toolCallId, String? code, String? content, String? customSessionId, String? level, String? toolType)}) → TResult

Available on ToolResult, provided by the ToolResultPatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>({TResult? response(String content, String toolCallId, String? customSessionId, String? toolName, String? toolType)?, TResult? error(String error, String toolCallId, String? code, String? content, String? customSessionId, String? level, String? toolType)?}) → TResult?

Available on ToolResult, provided by the ToolResultPatterns extension

A variant of when that fallback to returning null