Skip to content
pubscout

mermaid_flutter

0.3.2, released 5 weeks ago by roszkowski.dev

Native Flutter renderer for Mermaid diagrams using CustomPainter and TextPainter.

WASM-ready
$ flutter pub add mermaid_flutter
Source repository

What it does

Parses and renders Mermaid diagrams natively in Flutter without relying on SVGs, WebViews, or platform views. Provides interactive view controls like pan and zoom, node overrides, headless PNG export, and Material theme integration.

AI-written summary of version 0.3.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to render Mermaid diagrams natively inside a Flutter application.
  • You require interactive diagram exploration with pan, zoom, and node focus capabilities.
  • You want to generate PNG exports of diagrams in headless Flutter test environments.

Skip it when

  • You need features from mermaid.js that rely on HTML/DOM or unsupported theme-token references.
  • You are running in a pure Dart VM process where headless rendering runners are unavailable.

Strengths

  • Renders entirely native via CustomPainter without webviews or external web dependencies.
  • Supports interactive panning, zooming, node hover tooltips, and accessibility semantics.
  • Integrates smoothly with Material themes and ColorSchemes.

Weaknesses

  • Theme-token references inside source styles are not currently supported.
  • Headless PNG export requires a Flutter runner like `flutter test` or `flutter_tester`.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1

not documented

import 'package:flutter/material.dart';
import 'package:mermaid_flutter/mermaid_flutter.dart';

class Example extends StatelessWidget {
  const Example({super.key});

  @override
  Widget build(BuildContext context) {
    return const MermaidDiagram(
      source: '''
graph TD
  A[Start] --> B{Works?}
  B -->|yes| C[Ship it]
  B -->|no| A
''',
    );
  }
}

Alternatives

Packages that do the same job and could replace mermaid_flutter.

  • re_editor

    A lightweight text and code editor widget for Flutter with syntax highlighting and folding.

  • seo_renderer

    Renders Flutter text, link, and image widgets as HTML elements for SEO purposes on the web.

  • flutter_arc_text

    Flutter widget that renders text along an arc with configurable radius.

  • marquee_widget

    A Flutter widget that scrolls text and other widgets with RTL support.