buildViewportFrame method

ViewportFrame buildViewportFrame({
  1. required double viewTop,
  2. required double viewBottom,
  3. required double fallbackLineHeight,
})

Implementation

ViewportFrame buildViewportFrame({
  required double viewTop,
  required double viewBottom,
  required double fallbackLineHeight,
}) {
  final range = visibleRangeByHeight(
    viewTop: viewTop,
    viewBottom: viewBottom,
  );
  final total = _root.summary.lines;
  final summaries = <LineSummary>[];
  for (var i = range.firstLine; i <= range.lastLine && i < total; i++) {
    final line = _root.lineAt(i);
    final height = line.folded
        ? 0.0
        : (line.height == 0 ? fallbackLineHeight : line.height);
    summaries.add(
      LineSummary(height: height, lines: 1, isFolded: line.folded),
    );
  }
  return ViewportFrame(
    firstLine: range.firstLine,
    lastLine: range.lastLine,
    firstLineY: range.firstLineY,
    lines: summaries,
  );
}