CapabilityUtils class

Utility class for capability checking and safe execution Provides multiple approaches for different user levels and use cases

Constructors

CapabilityUtils.new()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

executeByCapabilities(dynamic provider, Map<LLMCapability, Future Function()> actions) Future<Map<String, dynamic>>
Execute multiple actions based on available capabilities Best for: Feature detection and conditional execution
getCapabilities(dynamic provider) Set<LLMCapability>
Get all supported capabilities for a provider
getCapabilitySummary(dynamic provider) Map<String, bool>
Get capability summary as human-readable map
getMissingCapabilities(dynamic provider, Set<LLMCapability> required) Set<LLMCapability>
Find missing capabilities for a set of requirements
hasCapability<T>(dynamic provider) bool
Simple capability check using interface type Best for: Quick checks, simple use cases
requireCapability<T, R>(dynamic provider, Future<R> action(T), {String? capabilityName}) Future<R>
Execute action safely with error handling Throws CapabilityError if not supported
supportsAllCapabilities(dynamic provider, Set<LLMCapability> capabilities) bool
Check multiple capabilities at once Best for: Complex feature requirements
supportsAnyCapability(dynamic provider, Set<LLMCapability> capabilities) bool
Check if provider supports any of the given capabilities Best for: Alternative feature implementations
supportsCapability(dynamic provider, LLMCapability capability) bool
Check capability using enum (requires ProviderCapabilities) Best for: Unified capability management, dynamic queries
validateProvider(dynamic provider, Set<LLMCapability> required) CapabilityValidationReport
Get validation report
validateRequirements(dynamic provider, Set<LLMCapability> required) bool
Validate provider meets minimum requirements
withAssistant<R>(dynamic provider, Future<R> action(AssistantCapability)) Future<R?>
Assistant helper
withCapability<T, R>(dynamic provider, Future<R> action(T)) Future<R?>
Execute action safely with capability check Returns null if capability not supported
withFallback<T, R>(dynamic provider, Future<R> action(T), Future<R> fallback()) Future<R>
Execute action with fallback if capability not supported Best for: Graceful degradation
withFileManagement<R>(dynamic provider, Future<R> action(FileManagementCapability)) Future<R?>
File management helper
withModeration<R>(dynamic provider, Future<R> action(ModerationCapability)) Future<R?>
Moderation helper