mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
parent
059de1537e
commit
39d7a019c1
@ -409,7 +409,9 @@ class RenderWrap extends RenderBox
|
||||
int childCount = 0;
|
||||
RenderBox child = firstChild;
|
||||
while (child != null) {
|
||||
final double childWidth = child.getMaxIntrinsicWidth(double.infinity);
|
||||
// TODO(chunhtai): use the new intrinsic API to calculate child sizes
|
||||
// once https://github.com/flutter/flutter/issues/48679 is fixed.
|
||||
final double childWidth = math.min(child.getMaxIntrinsicWidth(double.infinity), width);
|
||||
final double childHeight = child.getMaxIntrinsicHeight(childWidth);
|
||||
// There must be at least one child before we move on to the next run.
|
||||
if (childCount > 0 && runWidth + childWidth + spacing > width) {
|
||||
@ -437,7 +439,9 @@ class RenderWrap extends RenderBox
|
||||
int childCount = 0;
|
||||
RenderBox child = firstChild;
|
||||
while (child != null) {
|
||||
final double childHeight = child.getMaxIntrinsicHeight(double.infinity);
|
||||
// TODO(chunhtai): use the new intrinsic API to calculate child sizes
|
||||
// once https://github.com/flutter/flutter/issues/48679 is fixed.
|
||||
final double childHeight = math.min(child.getMaxIntrinsicHeight(double.infinity), height);
|
||||
final double childWidth = child.getMaxIntrinsicWidth(childHeight);
|
||||
// There must be at least one child before we move on to the next run.
|
||||
if (childCount > 0 && runHeight + childHeight + spacing > height) {
|
||||
|
||||
@ -70,6 +70,54 @@ void main() {
|
||||
expect(renderWrap.computeMinIntrinsicHeight(79), 250);
|
||||
});
|
||||
|
||||
test('Compute intrinsic height test for width-in-height-out children', () {
|
||||
const double lineHeight = 15.0;
|
||||
final RenderWrap renderWrap = RenderWrap();
|
||||
renderWrap.add(
|
||||
RenderParagraph(
|
||||
const TextSpan(
|
||||
text: 'A very very very very very very very very long text',
|
||||
style: TextStyle(fontSize: lineHeight),
|
||||
),
|
||||
textDirection: TextDirection.ltr,
|
||||
),
|
||||
);
|
||||
|
||||
renderWrap.spacing = 0;
|
||||
renderWrap.runSpacing = 0;
|
||||
renderWrap.direction = Axis.horizontal;
|
||||
|
||||
expect(renderWrap.computeMaxIntrinsicHeight(double.infinity), lineHeight);
|
||||
expect(renderWrap.computeMaxIntrinsicHeight(600), 2 * lineHeight);
|
||||
expect(renderWrap.computeMaxIntrinsicHeight(300), 3 * lineHeight);
|
||||
});
|
||||
|
||||
test('Compute intrinsic width test for height-in-width-out children', () {
|
||||
const double lineHeight = 15.0;
|
||||
final RenderWrap renderWrap = RenderWrap();
|
||||
renderWrap.add(
|
||||
// Rotates a width-in-height-out render object to make it height-in-width-out.
|
||||
RenderRotatedBox(
|
||||
quarterTurns: 1,
|
||||
child: RenderParagraph(
|
||||
const TextSpan(
|
||||
text: 'A very very very very very very very very long text',
|
||||
style: TextStyle(fontSize: lineHeight),
|
||||
),
|
||||
textDirection: TextDirection.ltr,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
renderWrap.spacing = 0;
|
||||
renderWrap.runSpacing = 0;
|
||||
renderWrap.direction = Axis.vertical;
|
||||
|
||||
expect(renderWrap.computeMaxIntrinsicWidth(double.infinity), lineHeight);
|
||||
expect(renderWrap.computeMaxIntrinsicWidth(600), 2 * lineHeight);
|
||||
expect(renderWrap.computeMaxIntrinsicWidth(300), 3 * lineHeight);
|
||||
});
|
||||
|
||||
test('Compute intrinsic width test', () {
|
||||
final List<RenderBox> children = <RenderBox>[
|
||||
RenderConstrainedBox(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user