SquigglyAnnotation constructor

SquigglyAnnotation({
  1. required List<PdfTextLine> textBoundsCollection,
})

Initializes a new instance of SquigglyAnnotation class.

The textBoundsCollection represents the bounds collection of the squiggly annotations that are added in the multiple lines of text.

Implementation

SquigglyAnnotation({
  required List<PdfTextLine> textBoundsCollection,
})  : assert(textBoundsCollection.isNotEmpty),
      assert(_checkTextMarkupRects(textBoundsCollection)),
      super(pageNumber: textBoundsCollection.first.pageNumber) {
  _textMarkupRects = <Rect>[];

  double minX = textBoundsCollection.first.bounds.left,
      minY = textBoundsCollection.first.bounds.top,
      maxX = textBoundsCollection.first.bounds.right,
      maxY = textBoundsCollection.first.bounds.bottom;

  for (final PdfTextLine textLine in textBoundsCollection) {
    final Rect rect = textLine.bounds;
    _textMarkupRects.add(rect);
    minX = minX < rect.left ? minX : rect.left;
    minY = minY < rect.top ? minY : rect.top;
    maxX = maxX > rect.right ? maxX : rect.right;
    maxY = maxY > rect.bottom ? maxY : rect.bottom;
  }

  setBounds(Rect.fromLTRB(minX, minY, maxX, maxY));
}