Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
30c2d77d
Unverified
Commit
30c2d77d
authored
Sep 20, 2022
by
Kate Lovett
Committed by
GitHub
Sep 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Deprecated RenderUnconstrainedBox (#111711)
parent
888b141a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
100 deletions
+21
-100
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+0
-85
box_test.dart
packages/flutter/test/rendering/box_test.dart
+21
-15
No files found.
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
30c2d77d
...
...
@@ -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.
///
...
...
packages/flutter/test/rendering/box_test.dart
View file @
30c2d77d
...
...
@@ -336,8 +336,8 @@ void main() {
});
test
(
'UnconstrainedBox expands to fit children'
,
()
{
final
Render
UnconstrainedBox
unconstrained
=
RenderUnconstrained
Box
(
constrain
edAxis:
Axis
.
horizontal
,
// This is reset to null below.
final
Render
ConstraintsTransformBox
unconstrained
=
RenderConstraintsTransform
Box
(
constrain
tsTransform:
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
.
constrain
edAxis
=
null
;
unconstrained
.
constrain
tsTransform
=
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
(
'Render
Unconstrained
Box#00000 NEEDS-LAYOUT NEEDS-PAINT DETACHED
\n
'
'Render
ConstraintsTransform
Box#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
Render
UnconstrainedBox
unconstrained
=
RenderUnconstrained
Box
(
constrain
edAxis:
Axis
.
horizontal
,
final
Render
ConstraintsTransformBox
unconstrained
=
RenderConstraintsTransform
Box
(
constrain
tsTransform:
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
Render
UnconstrainedBox
unconstrained
=
RenderUnconstrained
Box
(
constrain
edAxis:
Axis
.
vertical
,
final
Render
ConstraintsTransformBox
unconstrained
=
RenderConstraintsTransform
Box
(
constrain
tsTransform:
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
Render
Unconstrained
Box
box
;
final
Render
ConstraintsTransform
Box
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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment