setCustomRectifier method

void setCustomRectifier(
  1. List<Rect> rectifier(
    1. List<Rect>
    )?, {
  2. int? key,
})

Sets the custom rectifier, which is used to convert the raw rectangles of selected text into the displayed selection rects.

Implementation

void setCustomRectifier(
  List<Rect> Function(List<Rect>)? rectifier, {
  int? key,
}) {
  final k = key ?? 0;
  if (_rectifiers[k] != rectifier) {
    final selection = _selections[k];
    if (rectifier == null) {
      if (_rectifiers.containsKey(k)) {
        _rectifiers.remove(k);

        if (selection != null) {
          _selections[k] = selection.copyWith(
            version: selection.version - 1,
            rectifier: SelectionRectifiers.identity,
          );
        }
        notifyListeners();
      }
    } else {
      _rectifiers[k] = rectifier;
      if (selection != null) {
        _selections[k] = selection.copyWith(
          version: selection.version - 1,
          rectifier: rectifier,
        );
      }
      notifyListeners();
    }
  }
}