flutter_smooth_markdown 0.5.2 copy "flutter_smooth_markdown: ^0.5.2" to clipboard
flutter_smooth_markdown: ^0.5.2 copied to clipboard

High-performance Flutter markdown renderer with syntax highlighting, LaTeX math, tables, footnotes, SVG images, and real-time streaming support.

Flutter Smooth Markdown #

pub package popularity likes

A high-performance Flutter markdown renderer with syntax highlighting, LaTeX math formulas, tables, footnotes, SVG images, and real-time streaming support. Beautiful, customizable UI components for modern Flutter apps.

โœจ Features #

  • ๐Ÿš€ High Performance - AST-based parsing with optimized rendering
  • ๐Ÿ“ Full Markdown Support - Headers, paragraphs, lists, code blocks, blockquotes, links, tables, and more
  • ๐ŸŽจ Customizable Styling - Easy theming with light/dark mode support and preset themes
  • โœจ Enhanced UI Components - Beautiful code blocks with copy buttons, animated links, gradient blockquotes
  • ๐ŸŽฏ Extensible Builder System - Custom widget builders for any markdown element
  • ๐Ÿ’ป Code Blocks - Syntax highlighting with language tags and copy functionality
  • ๐Ÿ”— Links - Hover animations and external link indicators
  • ๐Ÿ“ Flexible Theme System - Multiple built-in themes (Default, GitHub, VS Code) with light/dark variants
  • ๐Ÿ“Š Table Support - Beautiful table rendering with proper styling and borders
  • ๐Ÿงฎ Math Formulas - LaTeX equation rendering with flutter_math_fork
  • ๐Ÿ“Ž Footnotes - Reference and definition support for academic writing
  • ๐Ÿ–ผ๏ธ SVG Images - Native SVG rendering support with flutter_svg
  • ๐Ÿ“‹ Details & Summary - Collapsible content sections with interactive expand/collapse
  • ๐ŸŒ Internationalization - Multi-language example app (6 languages supported)
  • ๐ŸŽฌ Streaming Support - Real-time markdown rendering with StreamMarkdown widget
  • ๐Ÿ”Œ Plugin System - Extensible parser plugins for custom syntax (Mention, Hashtag, Emoji, AI blocks)
  • ๐Ÿค– AI Chat Support - Built-in plugins for AI responses (Thinking, Artifact, Tool Call blocks)
  • ๐Ÿ“Š Mermaid Diagrams - Native rendering of flowcharts, sequence diagrams, pie charts, and Gantt charts

๐Ÿ“บ Demo #

Main Interface #

Main Interface

Code Blocks with Syntax Highlighting #

Enhanced Code Blocks

Math Formula Rendering (LaTeX) #

LaTeX Math Formulas

Streaming Support #

Real-time Streaming

Note: Run the example app to see all features in action: cd example && flutter run

๐Ÿš€ Getting Started #

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_smooth_markdown: ^0.5.2

Then run:

flutter pub get

Basic Usage #

import 'package:flutter_smooth_markdown/flutter_smooth_markdown.dart';

// Simple markdown rendering
SmoothMarkdown(
  data: '# Hello Markdown\n\nThis is **bold** and this is *italic*.',
  styleSheet: MarkdownStyleSheet.light(),
  onTapLink: (url) {
    // Handle link tap
    print('Tapped: $url');
  },
)

Using Enhanced Components #

Get beautiful UI with enhanced components for code blocks, links, blockquotes, and headers:

import 'package:flutter_smooth_markdown/flutter_smooth_markdown.dart';

// Create custom renderer with enhanced components
final customRenderer = MarkdownRenderer(
  styleSheet: MarkdownStyleSheet.light(),
);

// Register enhanced builders
customRenderer.builderRegistry
  ..register('code_block', const EnhancedCodeBlockBuilder())
  ..register('blockquote', const EnhancedBlockquoteBuilder())
  ..register('link', const EnhancedLinkBuilder())
  ..register('header', const EnhancedHeaderBuilder());

// Render markdown
final nodes = MarkdownParser().parse(markdownText);
final widget = customRenderer.render(nodes);

Enhanced components include:

  • Code blocks with copy button, language tags, and hover effects
  • Blockquotes with quote icons, gradient backgrounds, and shadows
  • Links with hover animations and external link indicators
  • Headers with decorative accents and gradient borders

See ไฝฟ็”จๅขžๅผบ็ป„ไปถ.md for detailed usage.

๐Ÿ“š Documentation #

For detailed documentation, see:

๐ŸŽฏ Supported Markdown Syntax #

Text Formatting #

  • Bold: **text** or __text__
  • Italic: *text* or _text_
  • Strikethrough: ~~text~~
  • Inline code: `code`

Headers #

# H1
## H2
### H3

Lists #

- Unordered list
1. Ordered list
- [ ] Task list
- [x] Completed task

Code Blocks #

```dart
void main() {
  print('Hello, World!');
}
```
[Link text](https://example.com)
![Flutter Logo](https://storage.googleapis.com/cms-storage-bucket/4fd0db61df0567c0f352.png)

Tables #

| Header 1 | Header 2 |
|----------|----------|
| Cell 1   | Cell 2   |

Math Formulas #

Inline math: $E = mc^2$

Block math:
$$
\int_{a}^{b} f(x) dx = F(b) - F(a)
$$

Footnotes #

This text has a footnote[^1].

[^1]: This is the footnote content.

SVG Images #

![Flutter Icon](https://raw.githubusercontent.com/simple-icons/simple-icons/develop/icons/flutter.svg)

Details & Summary (Collapsible Sections) #

<details>
<summary>Click to expand</summary>
This content is hidden by default and will only show when the user clicks the summary.
</details>

<details open>
<summary>Expanded by default</summary>
This section is expanded by default using the `open` attribute.
</details>

Plugin System (Custom Syntax) #

// Register custom parser plugins
final registry = ParserPluginRegistry();
registry.register(const MentionPlugin());    // @username
registry.register(const HashtagPlugin());    // #topic
registry.register(const EmojiPlugin());      // :smile:

// Use with parser
final parser = MarkdownParser(plugins: registry);
final nodes = parser.parse('@john mentioned #flutter :rocket:');

AI Chat Plugins #

// Built-in AI response plugins
final registry = ParserPluginRegistry();
registry.register(const ThinkingPlugin());   // <thinking>...</thinking>
registry.register(const ArtifactPlugin());   // <artifact>...</artifact>
registry.register(const ToolCallPlugin());   // <tool_use>...</tool_use>

// Render AI responses with thinking process
SmoothMarkdown(
  data: aiResponse,
  plugins: registry,
)

Mermaid Diagrams (Flowcharts, Gantt Charts, etc.) #

import 'package:flutter_smooth_markdown/flutter_smooth_markdown.dart';

// Render Mermaid diagrams natively
MermaidDiagram(
  code: '''
gantt
    title Project Timeline
    dateFormat YYYY-MM-DD

    section Planning
        Requirements :done, req, 2024-01-01, 14d
        Design :done, des, after req, 10d

    section Development
        Frontend :active, front, 2024-01-25, 30d
        Backend :crit, back, 2024-01-20, 35d

    section Release
        Testing :test, 2024-02-25, 10d
        Launch :milestone, launch, 2024-03-07, 0d
  ''',
  style: MermaidStyle.dark(),
)

Supported diagram types:

  • Flowcharts - graph TD/LR/BT/RL with various node shapes
  • Sequence Diagrams - Message flows between participants
  • Pie Charts - Data visualization with labels and percentages
  • Gantt Charts - Project timelines with tasks, sections, dependencies, and milestones
  • Timeline Diagrams - Historical timelines with periods and events
  • Interactive Mode - Pan/zoom support with auto-centering and adaptive scaling

๐Ÿ’ก Use Cases #

Perfect for building:

  • ๐Ÿ“ฑ Documentation Apps - Technical documentation with code examples
  • ๐Ÿ’ฌ Chat Applications - Rich text messaging with markdown support
  • ๐Ÿ“ Note-Taking Apps - Markdown editors and viewers
  • ๐ŸŽ“ Educational Platforms - Content with LaTeX formulas and code
  • ๐Ÿ“ฐ Content Management - Blog posts and articles with formatting
  • ๐Ÿค– AI Chat Interfaces - Real-time streaming markdown responses

๐ŸŽจ Theming #

The package includes multiple built-in themes with light and dark variants:

// Default themes
SmoothMarkdown(
  data: markdownText,
  styleSheet: MarkdownStyleSheet.light(), // or .dark()
)

// GitHub theme
SmoothMarkdown(
  data: markdownText,
  styleSheet: MarkdownStyleSheet.github(brightness: Brightness.light),
)

// VS Code theme
SmoothMarkdown(
  data: markdownText,
  styleSheet: MarkdownStyleSheet.vscode(brightness: Brightness.dark),
)

// Adapt to Flutter theme automatically
SmoothMarkdown(
  data: markdownText,
  styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context)),
)

// Custom theme
final customTheme = MarkdownStyleSheet.light().copyWith(
  h1Style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
  linkStyle: TextStyle(color: Colors.blue),
  codeBlockDecoration: BoxDecoration(
    color: Colors.grey[100],
    borderRadius: BorderRadius.circular(8),
  ),
);

See ไธป้ข˜็ณป็ปŸ.md for complete theming guide.

๐Ÿค Contributing #

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

๐Ÿ“„ License #

This project is licensed under the MIT License.

๐Ÿ” Keywords #

flutter markdown markdown renderer markdown widget syntax highlighting code highlighting latex math math formulas markdown parser markdown viewer rich text streaming markdown real-time rendering flutter ui markdown editor documentation note taking chat app ai chat markdown to widget

๐Ÿ“ Roadmap #

Completed #

  • โœ… Phase 1: Core project structure and AST node definitions
  • โœ… Phase 2: Markdown parser implementation (87+ tests passing)
  • โœ… Phase 3: Renderer implementation with widget builder system
  • โœ… Enhanced UI components (code blocks, blockquotes, links, headers)
  • โœ… Theme system with multiple presets (Default, GitHub, VS Code)
  • โœ… Example application with theme showcase
  • โœ… Syntax highlighting for code blocks with flutter_highlight
  • โœ… Table support with proper styling
  • โœ… Image rendering with caching (cached_network_image)
  • โœ… SVG image support (flutter_svg)
  • โœ… Math formula rendering (LaTeX with flutter_math_fork)
  • โœ… Footnote support (references and definitions)
  • โœ… Multi-language internationalization (Chinese, English, Japanese, Spanish, French, Korean)
  • โœ… Phase 4: Stream support for real-time rendering with StreamMarkdown widget
  • โœ… Streaming demo in example app
  • โœ… Details & Summary support for collapsible content sections
  • โœ… Plugin system for custom parsers (MentionPlugin, HashtagPlugin, EmojiPlugin, AdmonitionPlugin)
  • โœ… AI Chat plugins (ThinkingPlugin, ArtifactPlugin, ToolCallPlugin)
  • โœ… AI Chat Demo with Qwen3 Max integration and thinking mode
  • โœ… Mermaid diagram support (Flowcharts, Sequence, Pie Charts, Gantt Charts)

In Progress #

  • โŒ Performance optimization and benchmarking
  • โŒ API documentation and code comments

Planned #

  • โŒ More theme presets
  • โŒ Advanced table features (sorting, filtering)
  • โŒ Accessibility improvements (screen reader support)

Made with โค๏ธ for the Flutter community

4
likes
150
points
825
downloads

Publisher

unverified uploader

Weekly Downloads

High-performance Flutter markdown renderer with syntax highlighting, LaTeX math, tables, footnotes, SVG images, and real-time streaming support.

Repository (GitHub)
View/report issues
Contributing

Topics

#markdown #renderer #syntax-highlighting #mermaid #chart

Documentation

API reference

License

MIT (license)

Dependencies

cached_network_image, flutter, flutter_highlight, flutter_math_fork, flutter_svg, url_launcher

More

Packages that depend on flutter_smooth_markdown