drawLine method

void drawLine(
  1. Offset start,
  2. Offset end, {
  3. Color color = Colors.black,
  4. double thickness = 2,
  5. LineStyle style = LineStyle.redeBTExistente,
  6. String? layerTitle,
})

Implementation

void drawLine(
  Offset start,
  Offset end, {
  Color color = Colors.black,
  double thickness = 2,
  LineStyle style = LineStyle.redeBTExistente,
  String? layerTitle,
}) {
  if (start == end) return;

  final resolvedThickness = _resolveThickness(style, thickness);
  final path = switch (style) {
    LineStyle.redeMTProjetada => _buildDashedPath(
      start: start,
      end: end,
      color: color,
      thickness: resolvedThickness,
      dashLength: 28,
      gapLength: 14,
    ),
    LineStyle.redeMTExistente => _buildDashedPath(
      start: start,
      end: end,
      color: color,
      thickness: resolvedThickness,
      dashLength: 18,
      gapLength: 10,
    ),
    LineStyle.redeBTProjetada => <DrawModel?>[
      DrawModel(
        offset: start,
        color: color,
        strokeWidth: resolvedThickness,
      ),
      DrawModel(
        offset: end,
        color: color,
        strokeWidth: resolvedThickness,
      ),
    ],
    LineStyle.redeBTExistente => <DrawModel?>[
      DrawModel(
        offset: start,
        color: color,
        strokeWidth: resolvedThickness,
      ),
      DrawModel(
        offset: end,
        color: color,
        strokeWidth: resolvedThickness,
      ),
    ],
  };

  value = value.copyWith(
    currentPaintPath: path,
  );
  endPath();
}