setText method

void setText(
  1. String text,
  2. Canvas canvas,
  3. Size size,
  4. Offset location,
  5. String axis,
)

Implementation

void setText(
    String text, Canvas canvas, Size size, Offset location, String axis) {
  const textStyle = TextStyle(
    color: Colors.black,
    fontSize: 12,
  );

  var textSpan = TextSpan(
    text: text,
    style: textStyle,
  );

  var textPainter = TextPainter(
    text: textSpan,
    textDirection: TextDirection.ltr,
  );

  textPainter.layout(
    minWidth: 0,
    maxWidth: size.width,
  );

  textPainter.paint(
    canvas,
    Offset(axis == "x" ? location.dx - 10 : location.dx - 10,
        axis == "x" ? location.dy : location.dy - 10),
  );
}