segments property
List<PdfPathSegment>
get
segments
The path as segment objects.
Interpreter-built paths use a packed representation internally so dense CAD streams do not allocate one Dart object per segment. This getter materializes that representation lazily for compatibility with callers that need the object model. Rendering and serialization should use cursor to retain the allocation win.
Implementation
List<PdfPathSegment> get segments {
final direct = _segments;
if (direct != null) return direct;
final cached = _materialized[this];
if (cached != null) return cached;
final result = <PdfPathSegment>[];
final reader = cursor();
while (reader.moveNext()) {
result.add(switch (reader.verb) {
PdfPathVerb.moveTo => PdfMoveTo(reader.x1, reader.y1),
PdfPathVerb.lineTo => PdfLineTo(reader.x1, reader.y1),
PdfPathVerb.cubicTo => PdfCubicTo(
reader.x1, reader.y1, reader.x2, reader.y2, reader.x3, reader.y3),
PdfPathVerb.close => const PdfClosePath(),
});
}
_materialized[this] = result;
return result;
}