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
786d0306
Unverified
Commit
786d0306
authored
Nov 10, 2020
by
Michael Goderbauer
Committed by
GitHub
Nov 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assert for RenderFlex intrinsics if using baseline alignment (#70139)
parent
fb28ee28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
flex.dart
packages/flutter/lib/src/rendering/flex.dart
+10
-0
flex_test.dart
packages/flutter/test/rendering/flex_test.dart
+26
-0
No files found.
packages/flutter/lib/src/rendering/flex.dart
View file @
786d0306
...
...
@@ -512,6 +512,16 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
required
double
extent
,
// the extent in the direction that isn't the sizing direction
required
_ChildSizingFunction
childSize
,
// a method to find the size in the sizing direction
})
{
if
(
crossAxisAlignment
==
CrossAxisAlignment
.
baseline
)
{
// Intrinsics cannot be calculated without a full layout for
// baseline alignment. Throw an assertion and return 0.0 as documented
// on [RenderBox.computeMinIntrinsicWidth].
assert
(
RenderObject
.
debugCheckingIntrinsics
,
'Intrinsics are not available for CrossAxisAlignment.baseline.'
);
return
0.0
;
}
if
(
_direction
==
sizingDirection
)
{
// INTRINSIC MAIN SIZE
// Intrinsic main size is the smallest size the flex container can take
...
...
packages/flutter/test/rendering/flex_test.dart
View file @
786d0306
...
...
@@ -606,4 +606,30 @@ void main() {
expect
(
box2
.
size
,
const
Size
(
100.0
,
100.0
));
expect
(
box3
.
size
,
const
Size
(
100.0
,
100.0
));
});
test
(
'Intrinsics throw if alignment is baseline'
,
()
{
final
RenderDecoratedBox
box
=
RenderDecoratedBox
(
decoration:
const
BoxDecoration
(),
);
final
RenderFlex
flex
=
RenderFlex
(
textDirection:
TextDirection
.
ltr
,
children:
<
RenderBox
>[
box
],
crossAxisAlignment:
CrossAxisAlignment
.
baseline
,
textBaseline:
TextBaseline
.
alphabetic
,
);
layout
(
flex
,
constraints:
const
BoxConstraints
(
minWidth:
200.0
,
maxWidth:
200.0
,
minHeight:
200.0
,
maxHeight:
200.0
,
));
final
Matcher
cannotCalculateIntrinsics
=
throwsA
(
isAssertionError
.
having
(
(
AssertionError
e
)
=>
e
.
message
,
'message'
,
'Intrinsics are not available for CrossAxisAlignment.baseline.'
,
));
expect
(()
=>
flex
.
getMaxIntrinsicHeight
(
100
),
cannotCalculateIntrinsics
);
expect
(()
=>
flex
.
getMinIntrinsicHeight
(
100
),
cannotCalculateIntrinsics
);
expect
(()
=>
flex
.
getMaxIntrinsicWidth
(
100
),
cannotCalculateIntrinsics
);
expect
(()
=>
flex
.
getMinIntrinsicWidth
(
100
),
cannotCalculateIntrinsics
);
});
}
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