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
a0528423
Commit
a0528423
authored
Nov 03, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds FlexJustifyContent.collapse
parent
a0c8a4c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
flex.dart
packages/flutter/lib/src/rendering/flex.dart
+4
-1
flex_test.dart
packages/unit/test/widget/flex_test.dart
+62
-0
No files found.
packages/flutter/lib/src/rendering/flex.dart
View file @
a0528423
...
...
@@ -46,6 +46,8 @@ enum FlexJustifyContent {
spaceBetween
,
/// Place the free space evenly between the children as well as before and after the first and last child
spaceAround
,
/// Do not expand to fill the free space. None of the children may specify a flex factor.
collapse
,
}
/// How the children should be placed along the cross axis in a flex layout
...
...
@@ -337,7 +339,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
int
totalChildren
=
0
;
assert
(
constraints
!=
null
);
final
double
mainSize
=
(
_direction
==
FlexDirection
.
horizontal
)
?
constraints
.
constrainWidth
()
:
constraints
.
constrainHeight
();
final
bool
canFlex
=
mainSize
<
double
.
INFINITY
;
final
bool
canFlex
=
mainSize
<
double
.
INFINITY
&&
justifyContent
!=
FlexJustifyContent
.
collapse
;
double
crossSize
=
0.0
;
// This is determined as we lay out the children
double
freeSpace
=
canFlex
?
mainSize
:
0.0
;
RenderBox
child
=
firstChild
;
...
...
@@ -478,6 +480,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
switch
(
_justifyContent
)
{
case
FlexJustifyContent
.
start
:
case
FlexJustifyContent
.
collapse
:
leadingSpace
=
0.0
;
betweenSpace
=
0.0
;
break
;
...
...
packages/unit/test/widget/flex_test.dart
View file @
a0528423
...
...
@@ -42,4 +42,66 @@ void main() {
expect
(
didReceiveTap
,
isTrue
);
});
});
test
(
'Row, Column and FlexJustifyContent.collapse'
,
()
{
final
Key
flexKey
=
new
Key
(
'flexKey'
);
// Row without justifyContent: FlexJustifyContent.collapse
testWidgets
((
WidgetTester
tester
)
{
tester
.
pumpWidget
(
new
Center
(
child:
new
Row
([
new
Container
(
width:
10.0
,
height:
100.0
),
new
Container
(
width:
30.0
,
height:
100.0
)
],
key:
flexKey
)
));
Size
flexSize
=
tester
.
findElementByKey
(
flexKey
).
renderObject
.
size
;
expect
(
flexSize
.
width
,
equals
(
800.0
));
expect
(
flexSize
.
height
,
equals
(
100.0
));
// Row with justifyContent: FlexJustifyContent.collapse
tester
.
pumpWidget
(
new
Center
(
child:
new
Row
([
new
Container
(
width:
10.0
,
height:
100.0
),
new
Container
(
width:
30.0
,
height:
100.0
)
],
key:
flexKey
,
justifyContent:
FlexJustifyContent
.
collapse
)
));
flexSize
=
tester
.
findElementByKey
(
flexKey
).
renderObject
.
size
;
expect
(
flexSize
.
width
,
equals
(
40.0
));
expect
(
flexSize
.
height
,
equals
(
100.0
));
});
// Column without justifyContent: FlexJustifyContent.collapse
testWidgets
((
WidgetTester
tester
)
{
tester
.
pumpWidget
(
new
Center
(
child:
new
Column
([
new
Container
(
width:
100.0
,
height:
100.0
),
new
Container
(
width:
100.0
,
height:
150.0
)
],
key:
flexKey
)
));
Size
flexSize
=
tester
.
findElementByKey
(
flexKey
).
renderObject
.
size
;
expect
(
flexSize
.
width
,
equals
(
100.0
));
expect
(
flexSize
.
height
,
equals
(
600.0
));
// Column with justifyContent: FlexJustifyContent.collapse
tester
.
pumpWidget
(
new
Center
(
child:
new
Column
([
new
Container
(
width:
100.0
,
height:
100.0
),
new
Container
(
width:
100.0
,
height:
150.0
)
],
key:
flexKey
,
justifyContent:
FlexJustifyContent
.
collapse
)
));
flexSize
=
tester
.
findElementByKey
(
flexKey
).
renderObject
.
size
;
expect
(
flexSize
.
width
,
equals
(
100.0
));
expect
(
flexSize
.
height
,
equals
(
250.0
));
});
});
}
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