drawAnnotations method Null safety

void drawAnnotations(
  1. Painter painter,
  2. List<Vertex> vertices,
  3. {String color = 'red',
  4. int thickness = 3}
)

Draw a box on the supplied Painter around the detected object using Vertex values.

Implementation

static void drawAnnotations(Painter painter, List<Vertex> vertices,
    {String color = 'red', int thickness = 3}) {
  for (var index = 0; index < vertices.length - 1; index++) {
    final vStart = vertices[index];

    final vStop = vertices[index + 1];

    painter.drawLine(
        vStart.x, vStart.y, vStop.x, vStop.y, RgbColor.name(color),
        thickness: thickness);
  }

  painter.drawLine(vertices.last.x, vertices.last.y, vertices.first.x,
      vertices.first.y, RgbColor.name(color),
      thickness: thickness);
}