flutter_markdown_stream 0.2.0
flutter_markdown_stream: ^0.2.0 copied to clipboard
Flicker-free streaming Markdown widget for Flutter. Renders partial LLM token streams progressively, handling unclosed syntax gracefully.
Changelog #
0.2.0 #
- Breaking: Migrated from the discontinued
flutter_markdowntoflutter_markdown_plus(the official successor maintained by Foresight Mobile).sizedImageBuilderparameter renamed toimageBuilder.MarkdownSizedImageBuildertypedef replaced byMarkdownImageBuilder(signature changed from(Uri, MarkdownImageConfig)to(Uri, String?, String?)).
- Shortened package description to comply with pub.dev 60–180 character guideline.
0.1.0 #
Initial release of flutter_markdown_stream (formerly developed under the working
name flutter_markdown_stream).
MarkdownStreamwidget that rendersStream<String>of Markdown chunks progressively, with a one-frame debounce and optional cursor widget.- Rebuilds are scoped tightly via
ValueNotifier+ValueListenableBuilder; nosetStatein the hot path, so incoming tokens do not invalidate the outer widget subtree or restart unrelated animations. MarkdownStreamis generic over the chunk type:MarkdownStream<T>accepts anyStream<T>with achunkToTextextractor.Stream<String>remains the default and requires no extractor.StreamAdaptersutility with three composable converters for common non-string stream shapes:utf8Bytes(UTF-8 safe across byte splits),serverSentEvents(multi-chunk-safe SSE parser honouring[DONE]), andjsonField(nested JSON string extraction).SafeMarkdownParser.sanitizeutility that repairs unclosed bold, italic, strikethrough, inline code, fenced code blocks, inline links, and autolinks mid-stream.- Full
MarkdownBodypass-through:styleSheet,styleSheetTheme,syntaxHighlighter,onTapLink,onTapText,imageDirectory,blockSyntaxes,inlineSyntaxes,extensionSet,sizedImageBuilder,checkboxBuilder,bulletBuilder,builders,paddingBuilders,listItemCrossAxisAlignment,fitContent,shrinkWrap,softLineBreak,selectable— anything you can do withflutter_markdownyou can do withMarkdownStream. codeBuilderfires only for fenced (block) code, never for inline code. Abuilders['code']entry takes precedence overcodeBuilderif both are supplied.- Stream errors cancel the subscription cleanly (
cancelOnError: true) and are finalized through the sameonDonepath. - Family of eight cursor widgets:
BlinkingCursor,BarCursor,FadingCursor,PulsingCursor,TypingDotsCursor,WaveDotsCursor,SpinnerCursor,ShimmerCursor. All default to the ambient text colour, share the same customization shape (color, size,period), and dispose their tickers cleanly. flutter_lints-clean: zero analyzer issues. Targets Flutter>=3.27.0, Dart>=3.6.0. UsesColor.withValues(alpha:)(thewithOpacitysuccessor) andMarkdownBody.sizedImageBuilder(theimageBuildersuccessor) so the package stays green against current upstream APIs.- Full unit-test coverage of the sanitizer across adversarial inputs.
- Widget tests cover stream swap, cursor lifecycle, partial code fences.
- Example app demonstrating the widget with a simulated token stream and a gallery of every cursor.