isValid property Null safety

bool isValid

Whether this VerticalCaretMovementRun can still continue.

A VerticalCaretMovementRun run is valid if the underlying text layout hasn't changed.

The current value and the movePrevious, moveNext and moveByOffset methods must not be accessed when isValid is false.

Implementation

bool get isValid {
  if (!_isValid) {
    return false;
  }
  final List<ui.LineMetrics> newLineMetrics = _editable._textPainter.computeLineMetrics();
  // Use the implementation detail of the computeLineMetrics method to figure
  // out if the current text layout has been invalidated.
  if (!identical(newLineMetrics, _lineMetrics)) {
    _isValid = false;
  }
  return _isValid;
}