mono_flow

mono_flow editor

A node-based workflow editor for Flutter. Use it to build automation builders, AI agent pipelines, approval flows, ETL designers or any other visual programming UI. It works with mouse, trackpad and touch.

  • Canvas: smooth pan and zoom (drag, scroll, ⌘/Ctrl + scroll, pinch, trackpad), a dot grid, snap-to-grid, box select, a minimap and floating controls. Only the nodes in view are built, so large graphs stay fast.
  • Connections: drag from a port to connect. Connections to the same node, duplicates, connections into a trigger and cycles are rejected, and you can add your own rules. Drag a connection's end off an input to re-route it. Drop a connection on empty space, or click an output port, to add the next node already connected. Select a connection to insert a node into it.
  • Editing: undo and redo (a whole drag is one step, and typing is merged into one step), copy, paste, duplicate, delete, enable/disable, align and distribute, keyboard nudging and layered auto layout with animation.
  • Panels: a searchable node library (drag, or tap to append after the selection), and an inspector generated from your field definitions. With nothing selected, the inspector shows workflow health (unconnected nodes, empty branches).
  • Running: MonoFlowRunner executes the graph through your own executor. It follows the branch each node chooses, animates data along the connections, and shows timings, outputs and errors on the canvas and in a run log.
  • Ready to use: 16 standard nodes (triggers, logic, data, AI, actions), a sample workflow and a simulated executor.
  • Theming: light and dark themes plus copyWith, with no runtime dependencies. Workflows save to and load from JSON.

Install

dependencies:
  mono_flow: ^0.1.0

Quick start

import 'package:mono_flow/mono_flow.dart';

final controller = MonoFlowController(registry: MonoStandardNodes.registry)
  ..load(MonoStandardNodes.sampleGraph());

final runner = MonoFlowRunner(
  controller: controller,
  executor: MonoStandardNodes.simulate, // or your own
);

// A full editor in three widgets:
Row(children: [
  SizedBox(width: 268, child: MonoFlowPalette(controller: controller)),
  Expanded(child: MonoFlowCanvas(controller: controller)),
  SizedBox(width: 324, child: MonoFlowInspector(controller: controller, runner: runner)),
]);

await runner.run();

The example app adds a toolbar, JSON import and export, a run log and a responsive layout.

Define your own nodes

final registry = MonoNodeRegistry(
  categories: const [
    MonoNodeCategory(id: 'io', label: 'Inputs', color: Color(0xFF0284C7)),
    MonoNodeCategory(id: 'ops', label: 'Operations', color: Color(0xFF7C3AED)),
  ],
  types: [
    const MonoNodeType(
      id: 'form', label: 'Form submitted', category: 'io',
      icon: Icons.assignment_outlined, hasInput: false, // an entry point
    ),
    MonoNodeType(
      id: 'review', label: 'Review', category: 'ops', icon: Icons.fact_check,
      outputs: const [MonoPort('ok', label: 'Approved'), MonoPort('no', label: 'Rejected')],
      fields: const [
        MonoField.select('team', 'Team', options: ['Legal', 'Finance'], defaultValue: 'Legal'),
        MonoField.number('sla', 'SLA (hours)', defaultValue: 24),
        MonoField.toggle('urgent', 'Urgent'),
      ],
      summary: (d) => '${d['team']} · ${d['sla']}h',
    ),
  ],
);

Every node has at most one input and any number of outputs. A node with more than one output is a branch point. The inspector builds its form from fields, and the values are stored in node.data.

Edit the graph from code

final a = controller.addNode('form', Offset.zero);
final b = controller.addNode('review', const Offset(340, 0));
final error = controller.connect(a.id, 'out', b.id); // null when accepted

controller.updateNode(b.id, label: 'Legal review');
controller.setNodeValue(b.id, 'sla', 48);
controller.autoLayout();
controller.undo();
controller.fitView();

final json = controller.toJson();   // save anywhere
controller.loadJson(json);          // restore

Add your own connection rules:

MonoFlowController(
  registry: registry,
  connectionValidator: (c, source, port, target) =>
      target.type == 'email' && source.type == 'form' ? 'Review first' : null,
);

Execute a workflow

The runner starts from every entry node, or from the one you pass, and calls your executor for each node:

final runner = MonoFlowRunner(
  controller: controller,
  executor: (ex) async {
    final res = await api.execute(ex.node.type, ex.node.data, ex.inputs);
    if (!res.ok) return MonoNodeResult.failure(res.error);
    return MonoNodeResult.success(
      output: res.body,
      ports: ex.type.outputs.length > 1 ? [res.branch] : null, // which branch to follow
      message: '${res.status} in ${res.ms}ms',
    );
  },
);

ex.inputs contains the outputs of upstream nodes. Disabled nodes are bypassed. Exceptions are reported as failures, and a failure stops only its own branch. Use MonoRunLog(runner: runner) to show the log.

Customize the look

MonoFlowTheme(
  data: const MonoFlowThemeData.dark().copyWith(accent: Colors.teal),
  child: editor,
);

MonoFlowCanvas(
  controller: controller,
  nodeBuilder: (context, view) => MyNodeCard(view), // fill view.size; ports are drawn for you
  onRequestAddNode: (request) { /* your own picker */ },
  onContextMenu: (request) { /* your own menu */ },
  scrollToZoom: true, // a plain mouse wheel zooms
);

Node sizes are set by MonoFlowGeometry: the width, and the header and row heights. Because sizes are fixed, ports always line up and the canvas never has to measure widgets.

Keyboard shortcuts (canvas focused)

Action Keys
Undo / redo ⌘Z / ⇧⌘Z (Ctrl on Windows/Linux)
Copy / paste / duplicate ⌘C / ⌘V / ⌘D
Select all ⌘A
Delete ⌫ / Delete
Enable / disable E
Add node /
Zoom in / out / 100% + / − / 0
Fit / auto layout F / L
Nudge Arrow keys (⇧ for larger steps)
Pan Space + drag, middle mouse
Box select ⇧ + drag
Move without snapping ⌥ + drag

License

MIT

Libraries

mono_flow
A premium, node-based workflow editor for Flutter.