Unverified Commit 15b87226 authored by chunhtai's avatar chunhtai Committed by GitHub

Revert "Fix wrap compute max intrinsic width/height with spacing (#82t609)" (#82872)

This reverts commit 468471bf.
parent 66667507
...@@ -421,7 +421,7 @@ class RenderWrap extends RenderBox ...@@ -421,7 +421,7 @@ class RenderWrap extends RenderBox
double computeMaxIntrinsicWidth(double height) { double computeMaxIntrinsicWidth(double height) {
switch (direction) { switch (direction) {
case Axis.horizontal: case Axis.horizontal:
double width = math.max(childCount - 1, 0) * spacing; double width = 0.0;
RenderBox? child = firstChild; RenderBox? child = firstChild;
while (child != null) { while (child != null) {
width += child.getMaxIntrinsicWidth(double.infinity); width += child.getMaxIntrinsicWidth(double.infinity);
...@@ -455,7 +455,7 @@ class RenderWrap extends RenderBox ...@@ -455,7 +455,7 @@ class RenderWrap extends RenderBox
case Axis.horizontal: case Axis.horizontal:
return computeDryLayout(BoxConstraints(maxWidth: width)).height; return computeDryLayout(BoxConstraints(maxWidth: width)).height;
case Axis.vertical: case Axis.vertical:
double height = math.max(childCount - 1, 0) * spacing; double height = 0.0;
RenderBox? child = firstChild; RenderBox? child = firstChild;
while (child != null) { while (child != null) {
height += child.getMaxIntrinsicHeight(double.infinity); height += child.getMaxIntrinsicHeight(double.infinity);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -221,91 +219,4 @@ void main() { ...@@ -221,91 +219,4 @@ void main() {
expect(context.clipBehavior, equals(clip)); expect(context.clipBehavior, equals(clip));
} }
}); });
test('Compute max intrinsic height with spacing', () {
const double itemWidth = 64;
const double itemHeight = 32;
final RenderBox child = RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(
width: itemWidth,
height: itemHeight,
),
);
final RenderWrap renderWrap = RenderWrap();
renderWrap.add(child);
renderWrap.spacing = 5;
renderWrap.direction = Axis.vertical;
expect(renderWrap.computeMaxIntrinsicHeight(double.infinity), itemHeight);
final List<RenderBox> children = <RenderBox>[
RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(
width: itemWidth,
height: itemHeight,
),
),
RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(
width: itemWidth,
height: itemHeight,
),
),
];
children.forEach(renderWrap.add);
final double childrenHeight = renderWrap.childCount * itemHeight;
final double spacingHeight = math.max(renderWrap.childCount - 1, 0) * renderWrap.spacing;
expect(renderWrap.computeMaxIntrinsicHeight(double.infinity), childrenHeight + spacingHeight);
});
test('Compute max intrinsic width with spacing', () {
const double itemWidth = 64;
const double itemHeight = 32;
final RenderBox child = RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(
width: itemWidth,
height: itemHeight,
),
);
final RenderWrap renderWrap = RenderWrap();
renderWrap.add(child);
renderWrap.spacing = 5;
renderWrap.direction = Axis.horizontal;
expect(renderWrap.computeMaxIntrinsicWidth(double.infinity), itemWidth);
final List<RenderBox> children = <RenderBox>[
RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(
width: itemWidth,
height: itemHeight,
),
),
RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(
width: itemWidth,
height: itemHeight,
),
),
];
children.forEach(renderWrap.add);
final double childrenWidth = renderWrap.childCount * itemWidth;
final double spacingWidth = math.max(renderWrap.childCount - 1, 0) * renderWrap.spacing;
expect(renderWrap.computeMaxIntrinsicWidth(double.infinity), childrenWidth + spacingWidth);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment