Unverified Commit bc688cf0 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Make constraints a covariant argument in RenderBox.computeDryLayout() (#136432)

Some render box subclasses have a specific layout contract that is tightly coupled with other render box subclasses (e.g. two private classes in a local project file). In these cases, it is also possible that they use a constraints object that is a subclass of `BoxConstraints`. To allow for this, this change makes the `constraints` argument to `RenderBox.computeDryLayout()` a covariant argument.

For completeness' sake, this updates the other render objects in the rendering package to also use the covariant keyword for this argument.
parent 0f082889
...@@ -264,7 +264,8 @@ class RenderAnimatedSize extends RenderAligningShiftedBox { ...@@ -264,7 +264,8 @@ class RenderAnimatedSize extends RenderAligningShiftedBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (child == null || constraints.isTight) { if (child == null || constraints.isTight) {
return constraints.smallest; return constraints.smallest;
} }
......
...@@ -1906,7 +1906,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1906,7 +1906,7 @@ abstract class RenderBox extends RenderObject {
/// [debugCannotComputeDryLayout] from within an assert and return a dummy /// [debugCannotComputeDryLayout] from within an assert and return a dummy
/// value of `const Size(0, 0)`. /// value of `const Size(0, 0)`.
@protected @protected
Size computeDryLayout(BoxConstraints constraints) { Size computeDryLayout(covariant BoxConstraints constraints) {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
error: FlutterError.fromParts(<DiagnosticsNode>[ error: FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('The ${objectRuntimeType(this, 'RenderBox')} class does not implement "computeDryLayout".'), ErrorSummary('The ${objectRuntimeType(this, 'RenderBox')} class does not implement "computeDryLayout".'),
......
...@@ -393,7 +393,8 @@ class RenderCustomMultiChildLayoutBox extends RenderBox ...@@ -393,7 +393,8 @@ class RenderCustomMultiChildLayoutBox extends RenderBox
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _getSize(constraints); return _getSize(constraints);
} }
......
...@@ -2270,7 +2270,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin, ...@@ -2270,7 +2270,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
bool get _canComputeIntrinsics => _canComputeIntrinsicsCached ??= _canComputeDryLayoutForInlineWidgets(); bool get _canComputeIntrinsics => _canComputeIntrinsicsCached ??= _canComputeDryLayoutForInlineWidgets();
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (!_canComputeIntrinsics) { if (!_canComputeIntrinsics) {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Dry layout not available for alignments that require baseline.', reason: 'Dry layout not available for alignments that require baseline.',
...@@ -2630,7 +2631,8 @@ class _RenderEditableCustomPaint extends RenderBox { ...@@ -2630,7 +2631,8 @@ class _RenderEditableCustomPaint extends RenderBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) => constraints.biggest; @protected
Size computeDryLayout(covariant BoxConstraints constraints) => constraints.biggest;
} }
/// An interface that paints within a [RenderEditable]'s bounds, above or /// An interface that paints within a [RenderEditable]'s bounds, above or
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, TextStyle; import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, TextStyle;
import 'package:flutter/foundation.dart';
import 'box.dart'; import 'box.dart';
import 'object.dart'; import 'object.dart';
...@@ -77,7 +79,8 @@ class RenderErrorBox extends RenderBox { ...@@ -77,7 +79,8 @@ class RenderErrorBox extends RenderBox {
bool hitTestSelf(Offset position) => true; bool hitTestSelf(Offset position) => true;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.constrain(const Size(_kMaxWidth, _kMaxHeight)); return constraints.constrain(const Size(_kMaxWidth, _kMaxHeight));
} }
......
...@@ -653,7 +653,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -653,7 +653,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (!_canComputeIntrinsics) { if (!_canComputeIntrinsics) {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Dry layout cannot be computed for CrossAxisAlignment.baseline, which requires a full layout.', reason: 'Dry layout cannot be computed for CrossAxisAlignment.baseline, which requires a full layout.',
......
...@@ -299,7 +299,8 @@ class RenderFlow extends RenderBox ...@@ -299,7 +299,8 @@ class RenderFlow extends RenderBox
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _getSize(constraints); return _getSize(constraints);
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'dart:ui' as ui show Image; import 'dart:ui' as ui show Image;
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/foundation.dart';
import 'box.dart'; import 'box.dart';
import 'object.dart'; import 'object.dart';
...@@ -401,7 +402,8 @@ class RenderImage extends RenderBox { ...@@ -401,7 +402,8 @@ class RenderImage extends RenderBox {
bool hitTestSelf(Offset position) => true; bool hitTestSelf(Offset position) => true;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _sizeForConstraints(constraints); return _sizeForConstraints(constraints);
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'box.dart'; import 'box.dart';
import 'object.dart'; import 'object.dart';
...@@ -62,7 +64,8 @@ class RenderListBody extends RenderBox ...@@ -62,7 +64,8 @@ class RenderListBody extends RenderBox
Axis get mainAxis => axisDirectionToAxis(axisDirection); Axis get mainAxis => axisDirectionToAxis(axisDirection);
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
assert(_debugCheckConstraints(constraints)); assert(_debugCheckConstraints(constraints));
double mainAxisExtent = 0.0; double mainAxisExtent = 0.0;
RenderBox? child = firstChild; RenderBox? child = firstChild;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/foundation.dart';
import 'package:vector_math/vector_math_64.dart' show Matrix4; import 'package:vector_math/vector_math_64.dart' show Matrix4;
import 'box.dart'; import 'box.dart';
...@@ -615,7 +616,8 @@ class RenderListWheelViewport ...@@ -615,7 +616,8 @@ class RenderListWheelViewport
bool get sizedByParent => true; bool get sizedByParent => true;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.biggest; return constraints.biggest;
} }
......
...@@ -772,7 +772,8 @@ class RenderParagraph extends RenderBox with ContainerRenderObjectMixin<RenderBo ...@@ -772,7 +772,8 @@ class RenderParagraph extends RenderBox with ContainerRenderObjectMixin<RenderBo
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (!_canComputeIntrinsics()) { if (!_canComputeIntrinsics()) {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Dry layout not available for alignments that require baseline.', reason: 'Dry layout not available for alignments that require baseline.',
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// 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 'package:flutter/foundation.dart';
import 'box.dart'; import 'box.dart';
import 'layer.dart'; import 'layer.dart';
import 'object.dart'; import 'object.dart';
...@@ -157,7 +159,8 @@ class RenderPerformanceOverlay extends RenderBox { ...@@ -157,7 +159,8 @@ class RenderPerformanceOverlay extends RenderBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.constrain(Size(double.infinity, _intrinsicHeight)); return constraints.constrain(Size(double.infinity, _intrinsicHeight));
} }
......
...@@ -148,7 +148,8 @@ class RenderAndroidView extends PlatformViewRenderBox { ...@@ -148,7 +148,8 @@ class RenderAndroidView extends PlatformViewRenderBox {
bool get isRepaintBoundary => true; bool get isRepaintBoundary => true;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.biggest; return constraints.biggest;
} }
...@@ -319,7 +320,8 @@ abstract class RenderDarwinPlatformView<T extends DarwinPlatformViewController> ...@@ -319,7 +320,8 @@ abstract class RenderDarwinPlatformView<T extends DarwinPlatformViewController>
_UiKitViewGestureRecognizer? _gestureRecognizer; _UiKitViewGestureRecognizer? _gestureRecognizer;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.biggest; return constraints.biggest;
} }
...@@ -711,7 +713,8 @@ class PlatformViewRenderBox extends RenderBox with _PlatformViewGestureMixin { ...@@ -711,7 +713,8 @@ class PlatformViewRenderBox extends RenderBox with _PlatformViewGestureMixin {
bool get isRepaintBoundary => true; bool get isRepaintBoundary => true;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.biggest; return constraints.biggest;
} }
......
...@@ -95,7 +95,8 @@ mixin RenderProxyBoxMixin<T extends RenderBox> on RenderBox, RenderObjectWithChi ...@@ -95,7 +95,8 @@ mixin RenderProxyBoxMixin<T extends RenderBox> on RenderBox, RenderObjectWithChi
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return child?.getDryLayout(constraints) ?? computeSizeForNoChild(constraints); return child?.getDryLayout(constraints) ?? computeSizeForNoChild(constraints);
} }
...@@ -284,7 +285,8 @@ class RenderConstrainedBox extends RenderProxyBox { ...@@ -284,7 +285,8 @@ class RenderConstrainedBox extends RenderProxyBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (child != null) { if (child != null) {
return child!.getDryLayout(_additionalConstraints.enforce(constraints)); return child!.getDryLayout(_additionalConstraints.enforce(constraints));
} else { } else {
...@@ -383,7 +385,8 @@ class RenderLimitedBox extends RenderProxyBox { ...@@ -383,7 +385,8 @@ class RenderLimitedBox extends RenderProxyBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _computeSize( return _computeSize(
constraints: constraints, constraints: constraints,
layoutChild: ChildLayoutHelper.dryLayoutChild, layoutChild: ChildLayoutHelper.dryLayoutChild,
...@@ -565,7 +568,8 @@ class RenderAspectRatio extends RenderProxyBox { ...@@ -565,7 +568,8 @@ class RenderAspectRatio extends RenderProxyBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _applyAspectRatio(constraints); return _applyAspectRatio(constraints);
} }
...@@ -726,7 +730,8 @@ class RenderIntrinsicWidth extends RenderProxyBox { ...@@ -726,7 +730,8 @@ class RenderIntrinsicWidth extends RenderProxyBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _computeSize( return _computeSize(
layoutChild: ChildLayoutHelper.dryLayoutChild, layoutChild: ChildLayoutHelper.dryLayoutChild,
constraints: constraints, constraints: constraints,
...@@ -826,7 +831,8 @@ class RenderIntrinsicHeight extends RenderProxyBox { ...@@ -826,7 +831,8 @@ class RenderIntrinsicHeight extends RenderProxyBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _computeSize( return _computeSize(
layoutChild: ChildLayoutHelper.dryLayoutChild, layoutChild: ChildLayoutHelper.dryLayoutChild,
constraints: constraints, constraints: constraints,
...@@ -2672,7 +2678,8 @@ class RenderFittedBox extends RenderProxyBox { ...@@ -2672,7 +2678,8 @@ class RenderFittedBox extends RenderProxyBox {
// TODO(ianh): The intrinsic dimensions of this box are wrong. // TODO(ianh): The intrinsic dimensions of this box are wrong.
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (child != null) { if (child != null) {
final Size childSize = child!.getDryLayout(const BoxConstraints()); final Size childSize = child!.getDryLayout(const BoxConstraints());
...@@ -3693,7 +3700,8 @@ class RenderOffstage extends RenderProxyBox { ...@@ -3693,7 +3700,8 @@ class RenderOffstage extends RenderProxyBox {
bool get sizedByParent => offstage; bool get sizedByParent => offstage;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (offstage) { if (offstage) {
return constraints.smallest; return constraints.smallest;
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'box.dart'; import 'box.dart';
...@@ -74,7 +75,8 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB ...@@ -74,7 +75,8 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB
Matrix4? _paintTransform; Matrix4? _paintTransform;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (child == null) { if (child == null) {
return constraints.smallest; return constraints.smallest;
} }
......
...@@ -205,7 +205,8 @@ class RenderPadding extends RenderShiftedBox { ...@@ -205,7 +205,8 @@ class RenderPadding extends RenderShiftedBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
_resolve(); _resolve();
assert(_resolvedPadding != null); assert(_resolvedPadding != null);
if (child == null) { if (child == null) {
...@@ -428,7 +429,8 @@ class RenderPositionedBox extends RenderAligningShiftedBox { ...@@ -428,7 +429,8 @@ class RenderPositionedBox extends RenderAligningShiftedBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
final bool shrinkWrapWidth = _widthFactor != null || constraints.maxWidth == double.infinity; final bool shrinkWrapWidth = _widthFactor != null || constraints.maxWidth == double.infinity;
final bool shrinkWrapHeight = _heightFactor != null || constraints.maxHeight == double.infinity; final bool shrinkWrapHeight = _heightFactor != null || constraints.maxHeight == double.infinity;
if (child != null) { if (child != null) {
...@@ -637,7 +639,8 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox { ...@@ -637,7 +639,8 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
bool get sizedByParent => true; bool get sizedByParent => true;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.biggest; return constraints.biggest;
} }
...@@ -772,7 +775,8 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO ...@@ -772,7 +775,8 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
final Size? childSize = child?.getDryLayout(constraintsTransform(constraints)); final Size? childSize = child?.getDryLayout(constraintsTransform(constraints));
return childSize == null ? constraints.smallest : constraints.constrain(childSize); return childSize == null ? constraints.smallest : constraints.constrain(childSize);
} }
...@@ -940,7 +944,8 @@ class RenderSizedOverflowBox extends RenderAligningShiftedBox { ...@@ -940,7 +944,8 @@ class RenderSizedOverflowBox extends RenderAligningShiftedBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.constrain(_requestedSize); return constraints.constrain(_requestedSize);
} }
...@@ -1089,7 +1094,8 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox { ...@@ -1089,7 +1094,8 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (child != null) { if (child != null) {
final Size childSize = child!.getDryLayout(_getInnerConstraints(constraints)); final Size childSize = child!.getDryLayout(_getInnerConstraints(constraints));
return constraints.constrain(childSize); return constraints.constrain(childSize);
...@@ -1288,7 +1294,8 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox { ...@@ -1288,7 +1294,8 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _getSize(constraints); return _getSize(constraints);
} }
...@@ -1355,7 +1362,8 @@ class RenderBaseline extends RenderShiftedBox { ...@@ -1355,7 +1362,8 @@ class RenderBaseline extends RenderShiftedBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (child != null) { if (child != null) {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Baseline metrics are only available after a full layout.', reason: 'Baseline metrics are only available after a full layout.',
......
...@@ -547,7 +547,8 @@ class RenderStack extends RenderBox ...@@ -547,7 +547,8 @@ class RenderStack extends RenderBox
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _computeSize( return _computeSize(
constraints: constraints, constraints: constraints,
layoutChild: ChildLayoutHelper.dryLayoutChild, layoutChild: ChildLayoutHelper.dryLayoutChild,
......
...@@ -1024,7 +1024,8 @@ class RenderTable extends RenderBox { ...@@ -1024,7 +1024,8 @@ class RenderTable extends RenderBox {
} }
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
if (rows * columns == 0) { if (rows * columns == 0) {
return constraints.constrain(Size.zero); return constraints.constrain(Size.zero);
} }
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// 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 'package:flutter/foundation.dart';
import 'box.dart'; import 'box.dart';
import 'layer.dart'; import 'layer.dart';
import 'object.dart'; import 'object.dart';
...@@ -84,7 +86,8 @@ class TextureBox extends RenderBox { ...@@ -84,7 +86,8 @@ class TextureBox extends RenderBox {
bool get isRepaintBoundary => true; bool get isRepaintBoundary => true;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return constraints.biggest; return constraints.biggest;
} }
......
...@@ -1411,7 +1411,8 @@ class RenderViewport extends RenderViewportBase<SliverPhysicalContainerParentDat ...@@ -1411,7 +1411,8 @@ class RenderViewport extends RenderViewportBase<SliverPhysicalContainerParentDat
bool get sizedByParent => true; bool get sizedByParent => true;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
assert(debugCheckHasBoundedAxis(axis, constraints)); assert(debugCheckHasBoundedAxis(axis, constraints));
return constraints.biggest; return constraints.biggest;
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'box.dart'; import 'box.dart';
import 'layer.dart'; import 'layer.dart';
import 'layout_helper.dart'; import 'layout_helper.dart';
...@@ -493,7 +495,8 @@ class RenderWrap extends RenderBox ...@@ -493,7 +495,8 @@ class RenderWrap extends RenderBox
bool _hasVisualOverflow = false; bool _hasVisualOverflow = false;
@override @override
Size computeDryLayout(BoxConstraints constraints) { @protected
Size computeDryLayout(covariant BoxConstraints constraints) {
return _computeDryLayout(constraints); return _computeDryLayout(constraints);
} }
......
...@@ -1825,11 +1825,13 @@ void main() { ...@@ -1825,11 +1825,13 @@ void main() {
); );
layout(editable, constraints: constraints); layout(editable, constraints: constraints);
// ignore: invalid_use_of_protected_member
final double initialWidth = editable.computeDryLayout(constraints).width; final double initialWidth = editable.computeDryLayout(constraints).width;
expect(initialWidth, 500); expect(initialWidth, 500);
// Turn off forceLine. Now the width should be significantly smaller. // Turn off forceLine. Now the width should be significantly smaller.
editable.forceLine = false; editable.forceLine = false;
// ignore: invalid_use_of_protected_member
expect(editable.computeDryLayout(constraints).width, lessThan(initialWidth)); expect(editable.computeDryLayout(constraints).width, lessThan(initialWidth));
}); });
......
...@@ -961,10 +961,17 @@ void main() { ...@@ -961,10 +961,17 @@ void main() {
expect(fancyProxyBox.fancyMethod(), 36); expect(fancyProxyBox.fancyMethod(), 36);
// Box has behavior from RenderProxyBox: // Box has behavior from RenderProxyBox:
expect( expect(
// ignore: invalid_use_of_protected_member
fancyProxyBox.computeDryLayout(const BoxConstraints(minHeight: 8)), fancyProxyBox.computeDryLayout(const BoxConstraints(minHeight: 8)),
const Size(0, 8), const Size(0, 8),
); );
}); });
test('computeDryLayout constraints are covariant', () {
final RenderBoxWithTestConstraints box = RenderBoxWithTestConstraints();
const TestConstraints constraints = TestConstraints(testValue: 6);
expect(box.computeDryLayout(constraints), const Size.square(6));
});
} }
class _TestRectClipper extends CustomClipper<Rect> { class _TestRectClipper extends CustomClipper<Rect> {
...@@ -1087,3 +1094,19 @@ void expectAssertionError() { ...@@ -1087,3 +1094,19 @@ void expectAssertionError() {
} }
typedef DebugPaintCallback = void Function(PaintingContext context, Offset offset); typedef DebugPaintCallback = void Function(PaintingContext context, Offset offset);
class TestConstraints extends BoxConstraints {
const TestConstraints({
double extent = 100,
required this.testValue,
}) : super(maxWidth: extent, maxHeight: extent);
final double testValue;
}
class RenderBoxWithTestConstraints extends RenderProxyBox {
@override
Size computeDryLayout(TestConstraints constraints) {
return constraints.constrain(Size.square(constraints.testValue));
}
}
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