Skip to content
pubscout

diagram_editor

1.0.0, released 8 months ago by arokip.cz

Flutter library for building interactive diagram editors with pan, zoom, and link support

WASM-ready
$ flutter pub add diagram_editor
Source repository

What it does

Provides a DiagramEditor widget and a DiagramController to manage nodes and links on a canvas. Supports type‑safe custom data, serialization, and gesture callbacks.

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

Use it when

  • Need a diagram or flow‑chart editor in a Flutter app
  • Want pan/zoom and link creation without writing custom gesture logic
  • Require type‑safe component data and custom serialization

Skip it when

  • You only need simple static diagrams
  • You prefer a fully declarative widget tree without a controller
  • You need integration with a state‑management solution that expects a provider or bloc

Strengths

  • Type‑safe generics eliminate dynamic casts
  • Built‑in pan/zoom and link controls
  • Extensible via callbacks and custom painters
  • No external state‑management dependency

Weaknesses

  • Requires manual controller setup
  • No built‑in state‑management integration
  • Limited to Flutter (no pure Dart API)
  • Requires Flutter 3.3+ (Dart 3) for sealed classes

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1

Add dependency, import package, create DiagramController and DiagramEditor, no build_runner needed

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

class MyDiagram extends StatelessWidget {
  final controller = DiagramController<void, void>();
  @override
  Widget build(BuildContext context) {
    return DiagramEditor<void, void>(
      controller: controller,
      componentBuilder: (ctx, comp) => Container(
        color: Colors.blue,
        child: Center(child: Text(comp.id)),
      ),
      onCanvasTapUp: (details) {
        controller.addComponent(ComponentData(
          size: const Size(96, 72),
          position: controller.fromCanvasCoordinates(details.localPosition),
        ));
      },
      onComponentTap: (id) => controller.removeComponent(id),
    );
  }
}

Alternatives

Packages that do the same job and could replace diagram_editor.

  • vyuh_diagram_flutter

    Flutter canvas for diagrams with pan, zoom, selection and theming

  • over_react

    A library for building statically-typed React UI components using Dart.

  • tap_builder

    A simple widget for building interactive areas with customizable visual effects.

  • re_editor

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

Works with

Packages commonly used together with diagram_editor: ones it builds on, ones built on it, and its own family.