StreamHandler class

Manages streaming AI responses with unified handling.

Provides utilities for:

  • Accumulating text from chunks
  • Timeout handling
  • Error recovery
  • Completion callbacks

Constructors

StreamHandler({Duration? timeout})

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration?
Timeout for the entire stream.
final

Methods

accumulate(Stream<AIStreamChunk> stream) Stream<String>
Converts a stream of chunks into a stream of accumulated text.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
process(Stream<AIStreamChunk> stream, {OnChunkCallback? onChunk, OnCompleteCallback? onComplete, OnStreamErrorCallback? onError}) Future<String>
Processes a stream of chunks and returns the accumulated text.
toString() String
A string representation of this object.
inherited

Operators

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