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
ceca634e
Unverified
Commit
ceca634e
authored
Dec 09, 2020
by
Michael Goderbauer
Committed by
GitHub
Dec 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Constrain width/hight when asking child for intrinsics (#71880)
parent
53119af1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+4
-4
sized_box_test.dart
packages/flutter/test/widgets/sized_box_test.dart
+19
-0
No files found.
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
ceca634e
...
@@ -234,7 +234,7 @@ class RenderConstrainedBox extends RenderProxyBox {
...
@@ -234,7 +234,7 @@ class RenderConstrainedBox extends RenderProxyBox {
double
computeMinIntrinsicWidth
(
double
height
)
{
double
computeMinIntrinsicWidth
(
double
height
)
{
if
(
_additionalConstraints
.
hasBoundedWidth
&&
_additionalConstraints
.
hasTightWidth
)
if
(
_additionalConstraints
.
hasBoundedWidth
&&
_additionalConstraints
.
hasTightWidth
)
return
_additionalConstraints
.
minWidth
;
return
_additionalConstraints
.
minWidth
;
final
double
width
=
super
.
computeMinIntrinsicWidth
(
height
);
final
double
width
=
super
.
computeMinIntrinsicWidth
(
_additionalConstraints
.
constrainHeight
(
height
)
);
assert
(
width
.
isFinite
);
assert
(
width
.
isFinite
);
if
(!
_additionalConstraints
.
hasInfiniteWidth
)
if
(!
_additionalConstraints
.
hasInfiniteWidth
)
return
_additionalConstraints
.
constrainWidth
(
width
);
return
_additionalConstraints
.
constrainWidth
(
width
);
...
@@ -245,7 +245,7 @@ class RenderConstrainedBox extends RenderProxyBox {
...
@@ -245,7 +245,7 @@ class RenderConstrainedBox extends RenderProxyBox {
double
computeMaxIntrinsicWidth
(
double
height
)
{
double
computeMaxIntrinsicWidth
(
double
height
)
{
if
(
_additionalConstraints
.
hasBoundedWidth
&&
_additionalConstraints
.
hasTightWidth
)
if
(
_additionalConstraints
.
hasBoundedWidth
&&
_additionalConstraints
.
hasTightWidth
)
return
_additionalConstraints
.
minWidth
;
return
_additionalConstraints
.
minWidth
;
final
double
width
=
super
.
computeMaxIntrinsicWidth
(
height
);
final
double
width
=
super
.
computeMaxIntrinsicWidth
(
_additionalConstraints
.
constrainHeight
(
height
)
);
assert
(
width
.
isFinite
);
assert
(
width
.
isFinite
);
if
(!
_additionalConstraints
.
hasInfiniteWidth
)
if
(!
_additionalConstraints
.
hasInfiniteWidth
)
return
_additionalConstraints
.
constrainWidth
(
width
);
return
_additionalConstraints
.
constrainWidth
(
width
);
...
@@ -256,7 +256,7 @@ class RenderConstrainedBox extends RenderProxyBox {
...
@@ -256,7 +256,7 @@ class RenderConstrainedBox extends RenderProxyBox {
double
computeMinIntrinsicHeight
(
double
width
)
{
double
computeMinIntrinsicHeight
(
double
width
)
{
if
(
_additionalConstraints
.
hasBoundedHeight
&&
_additionalConstraints
.
hasTightHeight
)
if
(
_additionalConstraints
.
hasBoundedHeight
&&
_additionalConstraints
.
hasTightHeight
)
return
_additionalConstraints
.
minHeight
;
return
_additionalConstraints
.
minHeight
;
final
double
height
=
super
.
computeMinIntrinsicHeight
(
width
);
final
double
height
=
super
.
computeMinIntrinsicHeight
(
_additionalConstraints
.
constrainWidth
(
width
)
);
assert
(
height
.
isFinite
);
assert
(
height
.
isFinite
);
if
(!
_additionalConstraints
.
hasInfiniteHeight
)
if
(!
_additionalConstraints
.
hasInfiniteHeight
)
return
_additionalConstraints
.
constrainHeight
(
height
);
return
_additionalConstraints
.
constrainHeight
(
height
);
...
@@ -267,7 +267,7 @@ class RenderConstrainedBox extends RenderProxyBox {
...
@@ -267,7 +267,7 @@ class RenderConstrainedBox extends RenderProxyBox {
double
computeMaxIntrinsicHeight
(
double
width
)
{
double
computeMaxIntrinsicHeight
(
double
width
)
{
if
(
_additionalConstraints
.
hasBoundedHeight
&&
_additionalConstraints
.
hasTightHeight
)
if
(
_additionalConstraints
.
hasBoundedHeight
&&
_additionalConstraints
.
hasTightHeight
)
return
_additionalConstraints
.
minHeight
;
return
_additionalConstraints
.
minHeight
;
final
double
height
=
super
.
computeMaxIntrinsicHeight
(
width
);
final
double
height
=
super
.
computeMaxIntrinsicHeight
(
_additionalConstraints
.
constrainWidth
(
width
)
);
assert
(
height
.
isFinite
);
assert
(
height
.
isFinite
);
if
(!
_additionalConstraints
.
hasInfiniteHeight
)
if
(!
_additionalConstraints
.
hasInfiniteHeight
)
return
_additionalConstraints
.
constrainHeight
(
height
);
return
_additionalConstraints
.
constrainHeight
(
height
);
...
...
packages/flutter/test/widgets/sized_box_test.dart
View file @
ceca634e
...
@@ -190,4 +190,23 @@ void main() {
...
@@ -190,4 +190,23 @@ void main() {
);
);
expect
(
patient
.
currentContext
!.
size
,
equals
(
const
Size
(
0.0
,
0.0
)));
expect
(
patient
.
currentContext
!.
size
,
equals
(
const
Size
(
0.0
,
0.0
)));
});
});
testWidgets
(
'SizedBox constrains intrinsics'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/27293.
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
IntrinsicHeight
(
child:
SizedBox
(
width:
100
,
child:
Text
(
'This is a multi-line text.'
,
style:
TextStyle
(
height:
1.0
,
fontSize:
16
)),
),
),
),
),
);
expect
(
tester
.
getSize
(
find
.
text
(
'This is a multi-line text.'
)).
height
,
greaterThan
(
16
));
});
}
}
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