Skip to content
Core

Your first drawing ​

Create and edit shapes through one DiagramController. This focused example uses the same canvas, selection, text editing and undo verbs as the playground.

Loading interactive example…Open in new tab ↗
Opening the live canvas…

Try it ​

Click Add shape, drag the selected rectangle, delete it and undo the deletion. Double-click a shape's text to edit it. Reset example disposes this example's controller and starts a fresh fixture.

Source: apps/demo/lib/examples/basics/first_drawing.dart. See Controller for exact method signatures.

Source ​

dart
actions: {
  'Add shape': (s) =>
      s.edits.createShape(Shapes.rectangle, at: const DiagramPoint(230, 170)),
  'Select all': (s) => s.selectAll(),
  'Delete selection': (s) => s.edits.delete().requireAllowed(),
},