normalize method

void normalize(
  1. LineMetricsHelper? next,
  2. LineMetricsHelper info
)

Implementation

void normalize(LineMetricsHelper? next, LineMetricsHelper info) {
  // There is no need to normalize the last element, since it'll have already
  // been normalized
  if (next != null) {
    final outerRadius = info.outerRadius(this.outerRadius);
    var difference = () {
      final width = (info.rawWidth - next.rawWidth);
      return width.roundToDouble();
    }();

    // If the difference is negative, it means that the next element is a little
    // bigger than the current one. The current one takes the dimensions of
    // the next one
    if (difference.isNegative) {
      difference = -difference;
    }
    final differenceBigger = difference > outerRadius;
    if (!differenceBigger) {
      info._overridenX = next.x;
      info._overridenWidth = next.fullWidth;
    }
    // If the difference is positive, it means that the current element is a
    // little bigger than the next one. The next one takes the dimensions of
    // the current one
    else {
      final differenceBigger = difference > outerRadius;
      if (!differenceBigger) {
        next._overridenX = info.x;
        next._overridenWidth = info.fullWidth;
      }
    }
  }
}