Remove Deprecated RenderUnconstrainedBox (#111711)
This commit is contained in:
parent
888b141a50
commit
30c2d77d16
@ -879,91 +879,6 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
|
||||
}
|
||||
}
|
||||
|
||||
/// Renders a box, imposing no constraints on its child, allowing the child to
|
||||
/// render at its "natural" size.
|
||||
///
|
||||
/// The class is deprecated, use [RenderConstraintsTransformBox] instead.
|
||||
///
|
||||
/// This allows a child to render at the size it would render if it were alone
|
||||
/// on an infinite canvas with no constraints. This box will then attempt to
|
||||
/// adopt the same size, within the limits of its own constraints. If it ends
|
||||
/// up with a different size, it will align the child based on [alignment].
|
||||
/// If the box cannot expand enough to accommodate the entire child, the
|
||||
/// child will be clipped.
|
||||
///
|
||||
/// In debug mode, if the child overflows the box, a warning will be printed on
|
||||
/// the console, and black and yellow striped areas will appear where the
|
||||
/// overflow occurs.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [RenderConstrainedBox], which renders a box which imposes constraints
|
||||
/// on its child.
|
||||
/// * [RenderConstrainedOverflowBox], which renders a box that imposes different
|
||||
/// constraints on its child than it gets from its parent, possibly allowing
|
||||
/// the child to overflow the parent.
|
||||
/// * [RenderSizedOverflowBox], a render object that is a specific size but
|
||||
/// passes its original constraints through to its child, which it allows to
|
||||
/// overflow.
|
||||
///
|
||||
@Deprecated(
|
||||
'Use RenderConstraintsTransformBox instead. '
|
||||
'This feature was deprecated after v2.1.0-11.0.pre.',
|
||||
)
|
||||
class RenderUnconstrainedBox extends RenderConstraintsTransformBox {
|
||||
/// Create a render object that sizes itself to the child but does not
|
||||
/// pass the [constraints] down to that child.
|
||||
///
|
||||
/// The [alignment] and [clipBehavior] must not be null.
|
||||
@Deprecated(
|
||||
'Use RenderConstraintsTransformBox instead. '
|
||||
'This feature was deprecated after v2.1.0-11.0.pre.',
|
||||
)
|
||||
RenderUnconstrainedBox({
|
||||
required super.alignment,
|
||||
required super.textDirection,
|
||||
Axis? constrainedAxis,
|
||||
super.child,
|
||||
super.clipBehavior,
|
||||
}) : assert(alignment != null),
|
||||
assert(clipBehavior != null),
|
||||
_constrainedAxis = constrainedAxis,
|
||||
super(
|
||||
constraintsTransform: _convertAxis(constrainedAxis),
|
||||
);
|
||||
|
||||
/// The axis to retain constraints on, if any.
|
||||
///
|
||||
/// If not set, or set to null (the default), neither axis will retain its
|
||||
/// constraints. If set to [Axis.vertical], then vertical constraints will
|
||||
/// be retained, and if set to [Axis.horizontal], then horizontal constraints
|
||||
/// will be retained.
|
||||
Axis? get constrainedAxis => _constrainedAxis;
|
||||
Axis? _constrainedAxis;
|
||||
set constrainedAxis(Axis? value) {
|
||||
if (_constrainedAxis == value) {
|
||||
return;
|
||||
}
|
||||
_constrainedAxis = value;
|
||||
constraintsTransform = _convertAxis(constrainedAxis);
|
||||
}
|
||||
|
||||
static BoxConstraints _unconstrained(BoxConstraints constraints) => const BoxConstraints();
|
||||
static BoxConstraints _widthConstrained(BoxConstraints constraints) => constraints.widthConstraints();
|
||||
static BoxConstraints _heightConstrained(BoxConstraints constraints) => constraints.heightConstraints();
|
||||
static BoxConstraintsTransform _convertAxis(Axis? constrainedAxis) {
|
||||
if (constrainedAxis == null) {
|
||||
return _unconstrained;
|
||||
}
|
||||
switch (constrainedAxis) {
|
||||
case Axis.horizontal:
|
||||
return _widthConstrained;
|
||||
case Axis.vertical:
|
||||
return _heightConstrained;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A render object that is a specific size but passes its original constraints
|
||||
/// through to its child, which it allows to overflow.
|
||||
///
|
||||
|
@ -336,8 +336,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('UnconstrainedBox expands to fit children', () {
|
||||
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
|
||||
constrainedAxis: Axis.horizontal, // This is reset to null below.
|
||||
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.widthUnconstrained,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: RenderConstrainedBox(
|
||||
additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0),
|
||||
@ -354,7 +354,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
// Check that we can update the constrained axis to null.
|
||||
unconstrained.constrainedAxis = null;
|
||||
unconstrained.constraintsTransform = ConstraintsTransformBox.unconstrained;
|
||||
TestRenderingFlutterBinding.instance.reassembleApplication();
|
||||
|
||||
expect(unconstrained.size.width, equals(200.0), reason: 'unconstrained width');
|
||||
@ -362,7 +362,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('UnconstrainedBox handles vertical overflow', () {
|
||||
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
|
||||
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.unconstrained,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: RenderConstrainedBox(
|
||||
additionalConstraints: const BoxConstraints.tightFor(height: 200.0),
|
||||
@ -378,7 +379,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('UnconstrainedBox handles horizontal overflow', () {
|
||||
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
|
||||
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.unconstrained,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: RenderConstrainedBox(
|
||||
additionalConstraints: const BoxConstraints.tightFor(width: 200.0),
|
||||
@ -508,7 +510,8 @@ void main() {
|
||||
});
|
||||
|
||||
test ('getMinIntrinsicWidth error handling', () {
|
||||
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
|
||||
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.unconstrained,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: RenderConstrainedBox(
|
||||
additionalConstraints: const BoxConstraints.tightFor(width: 200.0),
|
||||
@ -632,7 +635,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('UnconstrainedBox.toStringDeep returns useful information', () {
|
||||
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
|
||||
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.unconstrained,
|
||||
textDirection: TextDirection.ltr,
|
||||
alignment: Alignment.center,
|
||||
);
|
||||
@ -642,7 +646,7 @@ void main() {
|
||||
expect(
|
||||
unconstrained.toStringDeep(minLevel: DiagnosticLevel.info),
|
||||
equalsIgnoringHashCodes(
|
||||
'RenderUnconstrainedBox#00000 NEEDS-LAYOUT NEEDS-PAINT DETACHED\n'
|
||||
'RenderConstraintsTransformBox#00000 NEEDS-LAYOUT NEEDS-PAINT DETACHED\n'
|
||||
' parentData: MISSING\n'
|
||||
' constraints: MISSING\n'
|
||||
' size: MISSING\n'
|
||||
@ -655,8 +659,8 @@ void main() {
|
||||
test('UnconstrainedBox honors constrainedAxis=Axis.horizontal', () {
|
||||
final RenderConstrainedBox flexible =
|
||||
RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(height: 200.0));
|
||||
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
|
||||
constrainedAxis: Axis.horizontal,
|
||||
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.heightUnconstrained,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: RenderFlex(
|
||||
textDirection: TextDirection.ltr,
|
||||
@ -678,8 +682,8 @@ void main() {
|
||||
test('UnconstrainedBox honors constrainedAxis=Axis.vertical', () {
|
||||
final RenderConstrainedBox flexible =
|
||||
RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(width: 200.0));
|
||||
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
|
||||
constrainedAxis: Axis.vertical,
|
||||
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.widthUnconstrained,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: RenderFlex(
|
||||
direction: Axis.vertical,
|
||||
@ -710,13 +714,14 @@ void main() {
|
||||
}
|
||||
|
||||
for (final Clip? clip in <Clip?>[null, ...Clip.values]) {
|
||||
final RenderUnconstrainedBox box;
|
||||
final RenderConstraintsTransformBox box;
|
||||
switch (clip) {
|
||||
case Clip.none:
|
||||
case Clip.hardEdge:
|
||||
case Clip.antiAlias:
|
||||
case Clip.antiAliasWithSaveLayer:
|
||||
box = RenderUnconstrainedBox(
|
||||
box = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.unconstrained,
|
||||
alignment: Alignment.center,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: box200x200,
|
||||
@ -724,7 +729,8 @@ void main() {
|
||||
);
|
||||
break;
|
||||
case null:
|
||||
box = RenderUnconstrainedBox(
|
||||
box = RenderConstraintsTransformBox(
|
||||
constraintsTransform: ConstraintsTransformBox.unconstrained,
|
||||
alignment: Alignment.center,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: box200x200,
|
||||
|
Loading…
x
Reference in New Issue
Block a user