anchorOffsetY method

double anchorOffsetY(
  1. int index,
  2. bool isHighlight,
  3. double? lineHeight,
  4. MainAxisAlignment? alignment,
)

Implementation

double anchorOffsetY(
  int index,
  bool isHighlight,
  double? lineHeight,
  MainAxisAlignment? alignment,
) {
  if (metrics.isEmpty || index < 0 || index >= metrics.length) return 0;
  final lh = lineHeight ?? getLineHeight(isHighlight, index);
  final hasTranslation = metrics[index].translationHeight > 0;
  final align = hasTranslation
      ? (alignment ?? style.selectionAlignment)
      : MainAxisAlignment.start;
  final currentLine = metrics[index];
  final activeHeight =
      isHighlight ? currentLine.activeHeight : currentLine.height;
  if (align == MainAxisAlignment.start) {
    return activeHeight / 2;
  } else if (align == MainAxisAlignment.end) {
    return activeHeight +
        style.translationLineGap +
        currentLine.translationHeight / 2;
  } else if (align == MainAxisAlignment.center) {
    return lh / 2;
  }
  return 0;
}