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
72619b86
Unverified
Commit
72619b86
authored
Aug 12, 2020
by
chunhtai
Committed by
GitHub
Aug 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix wrap intrinsic height calculation (#63420)
parent
41d41b32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
wrap.dart
packages/flutter/lib/src/rendering/wrap.dart
+4
-2
wrap_test.dart
packages/flutter/test/rendering/wrap_test.dart
+48
-0
No files found.
packages/flutter/lib/src/rendering/wrap.dart
View file @
72619b86
...
@@ -409,7 +409,8 @@ class RenderWrap extends RenderBox
...
@@ -409,7 +409,8 @@ class RenderWrap extends RenderBox
int
childCount
=
0
;
int
childCount
=
0
;
RenderBox
child
=
firstChild
;
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
while
(
child
!=
null
)
{
final
double
childWidth
=
child
.
getMaxIntrinsicWidth
(
double
.
infinity
);
// We want to make sure its width can only grow as big as the input width.
final
double
childWidth
=
math
.
min
(
child
.
getMaxIntrinsicWidth
(
double
.
infinity
),
width
);
final
double
childHeight
=
child
.
getMaxIntrinsicHeight
(
childWidth
);
final
double
childHeight
=
child
.
getMaxIntrinsicHeight
(
childWidth
);
// There must be at least one child before we move on to the next run.
// There must be at least one child before we move on to the next run.
if
(
childCount
>
0
&&
runWidth
+
childWidth
+
spacing
>
width
)
{
if
(
childCount
>
0
&&
runWidth
+
childWidth
+
spacing
>
width
)
{
...
@@ -437,7 +438,8 @@ class RenderWrap extends RenderBox
...
@@ -437,7 +438,8 @@ class RenderWrap extends RenderBox
int
childCount
=
0
;
int
childCount
=
0
;
RenderBox
child
=
firstChild
;
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
while
(
child
!=
null
)
{
final
double
childHeight
=
child
.
getMaxIntrinsicHeight
(
double
.
infinity
);
// We want to make sure its height can only grow as big as the input height.
final
double
childHeight
=
math
.
min
(
child
.
getMaxIntrinsicHeight
(
double
.
infinity
),
height
);
final
double
childWidth
=
child
.
getMaxIntrinsicWidth
(
childHeight
);
final
double
childWidth
=
child
.
getMaxIntrinsicWidth
(
childHeight
);
// There must be at least one child before we move on to the next run.
// There must be at least one child before we move on to the next run.
if
(
childCount
>
0
&&
runHeight
+
childHeight
+
spacing
>
height
)
{
if
(
childCount
>
0
&&
runHeight
+
childHeight
+
spacing
>
height
)
{
...
...
packages/flutter/test/rendering/wrap_test.dart
View file @
72619b86
...
@@ -70,6 +70,54 @@ void main() {
...
@@ -70,6 +70,54 @@ void main() {
expect
(
renderWrap
.
computeMinIntrinsicHeight
(
79
),
250
);
expect
(
renderWrap
.
computeMinIntrinsicHeight
(
79
),
250
);
});
});
test
(
'Compute intrinsic height test for width-in-height-out children'
,
()
{
const
double
lineHeight
=
15.0
;
final
RenderWrap
renderWrap
=
RenderWrap
();
renderWrap
.
add
(
RenderParagraph
(
const
TextSpan
(
text:
'A very very very very very very very very long text'
,
style:
TextStyle
(
fontSize:
lineHeight
),
),
textDirection:
TextDirection
.
ltr
,
),
);
renderWrap
.
spacing
=
0
;
renderWrap
.
runSpacing
=
0
;
renderWrap
.
direction
=
Axis
.
horizontal
;
expect
(
renderWrap
.
computeMaxIntrinsicHeight
(
double
.
infinity
),
lineHeight
);
expect
(
renderWrap
.
computeMaxIntrinsicHeight
(
600
),
2
*
lineHeight
);
expect
(
renderWrap
.
computeMaxIntrinsicHeight
(
300
),
3
*
lineHeight
);
});
test
(
'Compute intrinsic width test for height-in-width-out children'
,
()
{
const
double
lineHeight
=
15.0
;
final
RenderWrap
renderWrap
=
RenderWrap
();
renderWrap
.
add
(
// Rotates a width-in-height-out render object to make it height-in-width-out.
RenderRotatedBox
(
quarterTurns:
1
,
child:
RenderParagraph
(
const
TextSpan
(
text:
'A very very very very very very very very long text'
,
style:
TextStyle
(
fontSize:
lineHeight
),
),
textDirection:
TextDirection
.
ltr
,
)
),
);
renderWrap
.
spacing
=
0
;
renderWrap
.
runSpacing
=
0
;
renderWrap
.
direction
=
Axis
.
vertical
;
expect
(
renderWrap
.
computeMaxIntrinsicWidth
(
double
.
infinity
),
lineHeight
);
expect
(
renderWrap
.
computeMaxIntrinsicWidth
(
600
),
2
*
lineHeight
);
expect
(
renderWrap
.
computeMaxIntrinsicWidth
(
300
),
3
*
lineHeight
);
});
test
(
'Compute intrinsic width test'
,
()
{
test
(
'Compute intrinsic width test'
,
()
{
final
List
<
RenderBox
>
children
=
<
RenderBox
>[
final
List
<
RenderBox
>
children
=
<
RenderBox
>[
RenderConstrainedBox
(
RenderConstrainedBox
(
...
...
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