render method

  1. @override
void render(
  1. Canvas canvas
)

Implementation

@override
void render(Canvas canvas) {
  /// loop all children from graph node
  for (var items in graphNode.graphNodes) {
    /// if graphNode items is null breaks
    if (graphNode.item == null) break;

    /// if child item is  null then continue the loop
    if (items.item == null) continue;
    Paint paint = BasicPalette.red.paint();
    if (game.onDrawLine != null) {
      // get the pain from user implementation
      paint = game.onDrawLine!(items, graphNode) ?? BasicPalette.red.paint();
    }

    /// draw a line from parent to children
    canvas.drawLine(items.item!.center.toOffset(),
        graphNode.item!.center.toOffset(), paint);
  }
}