animated_streaming_markdown 0.2.0
animated_streaming_markdown: ^0.2.0 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
Table of Contents
About The Project #
animated_streaming_markdown provides 2 main layers:
- Parser:
StreamingMarkdownParseWorkerfor incrementalset/appendrequests - Renderer:
StreamingMarkdownRenderViewfor block rendering + token arrival 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.2.0 - Install packages:
flutter pub get
Usage #
1) Start parser worker and stream markdown #
final worker = StreamingMarkdownParseWorker();
await worker.start();
final setResult = await worker.request(
op: 'set',
text: '# Hello',
includeNodes: true,
);
final appendResult = await worker.request(
op: 'append',
text: '\n\nStreaming **markdown** chunk...',
includeNodes: true,
);
2) Render nodes with StreamingMarkdownRenderView #
StreamingMarkdownRenderView(
nodes: appendResult.renderNodes,
sliver: true,
tokenArrivalDelay: const Duration(milliseconds: 180),
tokenFadeInDuration: const Duration(milliseconds: 240),
enableTextSelection: true,
tokenAnimationBuilder: (
BuildContext context,
StreamingMarkdownAnimatedToken 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 #
StreamingMarkdownParseWorker.start()StreamingMarkdownParseWorker.request(op, text, includeNodes)StreamingMarkdownParseWorker.dispose()StreamingMarkdownRenderView(...)nodesslivertokenArrivalDelaytokenFadeInDuration/tokenFadeInRelativeToDelaytokenAnimationBuilderonTokenArrivalWaitenableTextSelectioncustomBlockBuilder
For a complete integration sample, check example/lib/markdown_cases_demo.dart.
Roadmap #
- ✅ Incremental parser worker (
set/append) - ✅ Streaming renderer for markdown block nodes
- ✅ Per-token custom animation builder API
- ✅ Example with multiple animation presets
- ❌ 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
License #
Distributed under the Apache-2.0 License. See LICENSE for details.
Contact #
- Repository: https://github.com/samnn152/streaming-markdown
- Issues: https://github.com/samnn152/streaming-markdown/issues