highlightLines method

void highlightLines(
  1. int startIndex,
  2. int endIndex,
  3. String? color
)

Implementation

void highlightLines(int startIndex, int endIndex, String? color) {
  final lines = document.collectAllStylesWithOffset(0, document.length);
  int currentLine = 0;
  for (final line in lines) {
    if (currentLine >= startIndex && currentLine <= endIndex) {
      document.format(
          line.offset,
          line.length ?? 0,
          color == null
              ? Attribute.clone(Attribute.highlight, null)
              : Attribute.clone(Attribute.highlight, color));
    }
    currentLine++;
  }
  notifyListeners();
}