showCustomWidgetsOnCanvasBackground method

  1. @override
List<Widget> showCustomWidgetsOnCanvasBackground(
  1. BuildContext context
)

Allows you to add any widget to the canvas.

The widgets will be displayed under all components and links.

Recommendation: use Positioned as the root widget.

Implementation

@override
List<Widget> showCustomWidgetsOnCanvasBackground(BuildContext context) {
  return [
    Visibility(
      visible: true,
      child: CustomPaint(
        size: Size.infinite,
        painter: GridPainter(
          offset: canvasReader.state.position / canvasReader.state.scale,
          scale: canvasReader.state.scale,
          lineWidth: (canvasReader.state.scale < 1.0)
              ? canvasReader.state.scale
              : 1.0,
          matchParentSize: false,
          lineColor: const Color(0xFF0D47A1).withAlpha(60),
        ),
      ),
    ),
    DragTarget<ComponentData>(
      builder: (_, __, ___) => const SizedBox.shrink(),
      onWillAcceptWithDetails: (DragTargetDetails<ComponentData> data) =>
          true,
      onAcceptWithDetails: (DragTargetDetails<ComponentData> details) =>
          _onAcceptWithDetails(details, context),
    ),
  ];
}