resolveOffset static method
Determines the correct location for an Offset given laid-out
paragraph
and a DrawableTextPosition
.
Implementation
static Offset resolveOffset(
Paragraph paragraph,
DrawableTextAnchorPosition anchor,
Offset offset,
) {
assert(paragraph != null); // ignore: unnecessary_null_comparison
assert(anchor != null); // ignore: unnecessary_null_comparison
assert(offset != null); // ignore: unnecessary_null_comparison
switch (anchor) {
case DrawableTextAnchorPosition.middle:
return Offset(
offset.dx - paragraph.longestLine / 2,
offset.dy - paragraph.alphabeticBaseline,
);
case DrawableTextAnchorPosition.end:
return Offset(
offset.dx - paragraph.longestLine,
offset.dy - paragraph.alphabeticBaseline,
);
case DrawableTextAnchorPosition.start:
return Offset(
offset.dx,
offset.dy - paragraph.alphabeticBaseline,
);
default:
return offset;
}
}