- override
Do the work of computing the layout for this render object.
Do not call this function directly: call layout
instead. This function
is called by layout
when there is actually work to be done by this
render object during layout. The layout constraints provided by your
parent are available via the constraints
getter.
If sizedByParent
is true, then this function should not actually change
the dimensions of this render object. Instead, that work should be done by
performResize
. If sizedByParent
is false, then this function should
both change the dimensions of this render object and instruct its children
to layout.
In implementing this function, you must call layout
on each of your
children, passing true for parentUsesSize if your layout information is
dependent on your child's layout information. Passing true for
parentUsesSize ensures that this render object will undergo layout if the
child undergoes layout. Otherwise, the child can changes its layout
information without informing this render object.
Source
@override void performLayout() { _layoutText(minWidth: constraints.minWidth, maxWidth: constraints.maxWidth); // We grab _textPainter.size here because assigning to `size` will trigger // us to validate our intrinsic sizes, which will change _textPainter's // layout because the intrinsic size calculations are destructive. final Size textSize = _textPainter.size; size = constraints.constrain(textSize); final bool didOverflowWidth = size.width < textSize.width; // TODO(abarth): We're only measuring the sizes of the line boxes here. If // the glyphs draw outside the line boxes, we might think that there isn't // visual overflow when there actually is visual overflow. This can become // a problem if we start having horizontal overflow and introduce a clip // that affects the actual (but undetected) vertical overflow. _hasVisualOverflow = didOverflowWidth || size.height < textSize.height; if (didOverflowWidth) { switch (_overflow) { case TextOverflow.clip: case TextOverflow.ellipsis: _overflowShader = null; break; case TextOverflow.fade: TextPainter fadeWidthPainter = new TextPainter( text: new TextSpan(style: _textPainter.text.style, text: '\u2026'), textScaleFactor: textScaleFactor )..layout(); final double fadeEnd = size.width; final double fadeStart = fadeEnd - fadeWidthPainter.width; // TODO(abarth): This shader has an LTR bias. _overflowShader = new ui.Gradient.linear( <Point>[new Point(fadeStart, 0.0), new Point(fadeEnd, 0.0)], <Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)] ); break; } } else { _overflowShader = null; } }