animated_streaming_markdown 0.3.2
animated_streaming_markdown: ^0.3.2 copied to clipboard
Flutter markdown streaming package for Android/iOS/macOS/Linux/Windows (web is not supported).
animated_streaming_markdown
Streaming Markdown parser + renderer for Flutter, optimized for incremental append flows.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
[animated_streaming_markdown Gemini streaming Markdown demo]
Table of Contents
About The Project #
animated_streaming_markdown provides 2 main layers:
- Parser:
MarkdownStreamParserfor typedreplace/appendrequests - Renderer:
AnimatedStreamingMarkdownfor block rendering + token reveal animations
It is designed for chat-like or streaming text interfaces where markdown arrives progressively and needs stable UI updates.
Built With #
Getting Started #
Prerequisites #
- Flutter
>=3.0.0 - Dart SDK
>=2.17.0 <4.0.0 - Native toolchain for your target platform (Android/iOS/macOS/Linux/Windows)
Installation #
- Add dependency:
dependencies: animated_streaming_markdown: ^0.3.2 - Install packages:
flutter pub get
Usage #
1) Start parser worker and stream markdown #
final parser = MarkdownStreamParser();
await parser.start();
final setResult = await parser.replace('# Hello');
final appendResult = await parser.append('\n\nStreaming **markdown** chunk...');
2) Render blocks with AnimatedStreamingMarkdown #
AnimatedStreamingMarkdown(
blocks: appendResult.blocks,
asSliver: true,
tokenStaggerDelay: const Duration(milliseconds: 180),
tokenAnimationDuration: const Duration(milliseconds: 240),
enableSelection: true,
tokenAnimationBuilder: (
BuildContext context,
AnimatedMarkdownToken token,
) {
final t = Curves.easeOutCubic.transform(token.value);
return Transform.translate(
offset: Offset(0, (1 - t) * 8),
child: Opacity(opacity: t, child: token.child),
);
},
);
3) Important APIs #
MarkdownStreamParser.start()MarkdownStreamParser.replace(markdown)MarkdownStreamParser.append(chunk)MarkdownStreamParser.parse(operation, text)MarkdownStreamParser.dispose()AnimatedStreamingMarkdown(...)blocksasSlivertokenStaggerDelaytokenAnimationDuration/tokenAnimationDurationFactortokenAnimationBuilderonTokenDelayenableSelectionblockBuilder
For a complete integration sample, check example/lib/src/demos/markdown_cases_demo.dart.
Documentation #
- Package page
- API reference
- Example app
- Migration guide: 0.2.x to 0.3.x
The documentation site is built with Docusaurus from docs/ and
deployed to GitHub Pages by Deploy Documentation.
Run the docs site locally:
cd website
npm ci
npm run start
Build the static site:
cd website
npm run build
Migration notes for 0.3.0 #
0.3.0 keeps the 0.2.x API available, but the preferred names now describe
the package behavior more directly:
| 0.2.x name | 0.3.x preferred name |
|---|---|
StreamingMarkdownParseWorker |
MarkdownStreamParser |
request(op: 'set', ...) |
replace(markdown) |
request(op: 'append', ...) |
append(chunk) |
StreamingMarkdownParseResult.renderNodes |
MarkdownParseResult.blocks |
StreamingMarkdownRenderView |
AnimatedStreamingMarkdown |
nodes |
blocks |
sliver |
asSliver |
tokenArrivalDelay |
tokenStaggerDelay |
tokenFadeInDuration |
tokenAnimationDuration |
tokenFadeInRelativeToDelay |
tokenAnimationDurationFactor |
allowUnclosedInlineDelimiters |
allowIncompleteInlineSyntax |
enableTextSelection |
enableSelection |
customBlockBuilder |
blockBuilder |
markdownTheme |
theme |
Roadmap #
- Done: Incremental parser worker (
replace/append) - Done: Streaming renderer for markdown block nodes
- Done: Per-token custom animation builder API
- Done: Example with multiple animation presets
- Done: Docusaurus documentation site for
samnn.dev - Planned: Convenience constructors and helper functions
- Planned: Code block copy and LaTeX support research
- Planned: Richer copy modes and improved multi-content drag selection
- Planned: More parser/renderer benchmark scenarios
See the open issues for proposed features and known issues.
Contributing #
Contributions are welcome.
- Fork the project
- Create your branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m "Add your feature") - Push branch (
git push origin feature/your-feature) - Open a Pull Request
See CONTRIBUTING.md for local setup, repository layout, and quality gates.
License #
Distributed under the Apache-2.0 License. See LICENSE for details.
Contact #
- Documentation: https://pub.dev/documentation/animated_streaming_markdown/latest/
- Repository: https://github.com/samnn152/streaming-markdown
- Issues: https://github.com/samnn152/streaming-markdown/issues