Skip to content

Grids and snapping

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

Drag a card with Snap on, then compare with Snap off. Hide removes the background without changing snapping. Choose 20 or 40 world units for the shared interval. Dots, lines and the custom cross pattern use that same interval; the custom pattern adds a major line every five intervals.

All controls update DrawingConfiguration.grid through the session. They do not rewrite document elements or enter document history. Moving a card remains an ordinary admitted edit and can be undone. Reset restores the fixture and its initial visible, snapping grid.

See Grids API for normalization, layer limits and rotation snapping.

Source

dart
void configureGrid(
  DrawingSession session, {
  bool? visible,
  bool? snap,
  double? size,
  DiagramGridPattern? pattern,
}) => session.setConfiguration(
  session.canvasConfiguration.copyWith(
    grid: session.canvasConfiguration.grid.copyWith(
      visible: visible,
      snap: snap,
      size: size,
      pattern: pattern,
    ),
  ),
);