drawXLabelValue method Null safety

void drawXLabelValue(
  1. Canvas canvas,
  2. Size size,
  3. String valueLabel,
  4. String valueBottomLabel,
  5. Offset barCenter,
  6. double barHeight,
  7. double barHeightBottom
)

x축 라벨을 그립니다.

Implementation

void drawXLabelValue(Canvas canvas, Size size, String valueLabel, String valueBottomLabel, Offset barCenter, double barHeight, double barHeightBottom) {
  final xLabelValuePainter = TextPainter(
    text: TextSpan(text: valueLabel, style: TextStyle(color: Colors.black, fontSize: xLabelValueSize)),
    textAlign: TextAlign.center,
    textDirection: TextDirection.ltr,
  );
  xLabelValuePainter.layout(minWidth: barWidth, maxWidth: barWidth + (barSpace / 2));

  final xBottomLabelValuePainter = TextPainter(
    text: TextSpan(text: valueBottomLabel, style: TextStyle(color: Colors.black, fontSize: xLabelValueSize)),
    textAlign: TextAlign.center,
    textDirection: TextDirection.ltr,
  );
  xBottomLabelValuePainter.layout(minWidth: barWidth, maxWidth: barWidth + (barSpace / 2));
  double dx = barCenter.dx - (barWidth / 2);
  double dy = baseOffsetY +
      size.height -
      (xLabelDaySize + xLabelDayMargin) -
      (xLabelHourSize + xLabelHourMargin) -
      (xLabelBirthDaySize + xLabelBirthDayMargin) -
      (barHeight + horizontalLineHeight + xLabelValueSize + xLabelValueMargin);

  xLabelValuePainter.paint(canvas, Offset(dx, dy));
  if (isBiDirectional) {
    double dyBottom = baseOffsetY +
        size.height -
        (xLabelDaySize + xLabelDayMargin) -
        (xLabelHourSize + xLabelHourMargin) -
        (xLabelBirthDaySize + xLabelBirthDayMargin) +
        (barHeightBottom + horizontalLineHeight + xLabelValueSize - xLabelValueMargin);
    xBottomLabelValuePainter.paint(canvas, Offset(dx, dyBottom));
  }
}