drawBar method Null safety

List drawBar(
  1. Canvas canvas,
  2. Size size,
  3. List<BarDataHour?> barDataHour,
  4. double offsetDx,
  5. int i
)

바를 그립니다.

Implementation

List<dynamic> drawBar(Canvas canvas, Size size, List<BarDataHour?> barDataHour, double offsetDx, int i) {
  double barHeight = barDataHour[i]!.realValue.toDouble() * barHeightRatio;
  if (barDataHour[i]!.realValue == 0) barHeight = 1;
  double barHeightBottom = barDataHour[i]!.realValueBottom.toDouble() * barHeightRatio;
  Offset barCenter = Offset(
    offsetDx + barStartOffsetX + yLabelWidth + yLabelMargin + (barWidth / 2) + (barWidth + barSpace) * i,
    baseOffsetY + size.height - xLabelDaySize - xLabelDayMargin - xLabelHourSize - xLabelHourMargin - xLabelBirthDaySize - xLabelBirthDayMargin - horizontalLineHeight - (barHeight / 2),
  );

  if (isBiDirectional) {
    var barCenterBottom = Offset(
      offsetDx + barStartOffsetX + yLabelWidth + yLabelMargin + (barWidth / 2) + (barWidth + barSpace) * i,
      baseOffsetY + size.height - xLabelDaySize - xLabelDayMargin - xLabelHourSize - xLabelHourMargin - xLabelBirthDaySize - xLabelBirthDayMargin - horizontalLineHeight + (barHeightBottom / 2),
    );
    canvas.drawRect(Rect.fromCenter(center: barCenter, width: barWidth, height: barHeight), barDataHour[i]!.isHighlighted ? barPaintStandHighlight : barPaintStand);
    canvas.drawRect(Rect.fromCenter(center: barCenterBottom, width: barWidth, height: barHeightBottom), barDataHour[i]!.isHighlighted ? barPaintSitHighlight : barPaintSit);
  } else {
    canvas.drawRect(Rect.fromCenter(center: barCenter, width: barWidth, height: barHeight), barDataHour[i]!.isHighlighted ? barPaintHighlight : barPaint);
  }

  return [barCenter, barHeight, barHeightBottom];
}