StreamingMarkdown class
Reveals text progressively, rebuilding only the part that can still change.
The source is split at the last safe blank line. Everything before it is settled — built once, cached, and wrapped in a RepaintBoundary, so it is neither rebuilt nor repainted as the reply continues. Only the tail is rebuilt per frame.
That split is the whole performance story. Measured on a 7.7 kB reply, a whole-document rebuild costs about 14 ms; a tail-only rebuild costs about 1.3 ms and, unlike the first, does not grow as the reply gets longer.
Streaming is data, not a Stream: rebuild this widget with a longer text
while isStreaming is true. When it flips to false the remainder
fast-forwards in, so a finished reply never trickles.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- StreamingMarkdown
Constructors
- StreamingMarkdown({Key? key, required String text, required StreamingMarkdownBuilder builder, bool isStreaming = true, double charactersPerSecond = 300})
-
Creates a revealing Markdown view.
const
Properties
- builder → StreamingMarkdownBuilder
-
Renders a slice of the source. The same builder is used for the settled
prefix and the live tail.
final
- charactersPerSecond → double
-
Baseline reveal speed. The reveal goes faster than this on its own
whenever it would otherwise fall behind the incoming text.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isStreaming → bool
-
Whether more text may still arrive.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- text → String
-
Everything received so far.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StreamingMarkdown> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited