computeLineMetrics method
Returns the full list of MongolLineMetrics
that describe in detail the various
metrics of each laid out line.
The MongolLineMetrics
list is presented in the order of the lines they represent.
For example, the first line is in the zeroth index.
MongolLineMetrics
contains measurements such as ascent, descent, baseline, and
height for the line as a whole, and may be useful for aligning additional
widgets to a particular line.
Valid only after layout has been called.
Implementation
List<MongolLineMetrics> computeLineMetrics() {
assert(_debugAssertTextLayoutIsValid);
assert(!_debugNeedsRelayout);
final _TextPainterLayoutCacheWithOffset layout = _layoutCache!;
final Offset offset = layout.paintOffset;
if (!offset.dy.isFinite || !offset.dx.isFinite) {
return const <MongolLineMetrics>[];
}
final List<MongolLineMetrics> rawMetrics = layout.lineMetrics;
return offset == Offset.zero
? rawMetrics
: rawMetrics
.map((MongolLineMetrics metrics) =>
_shiftLineMetrics(metrics, offset))
.toList(growable: false);
}