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
8ac14f86
Commit
8ac14f86
authored
Sep 15, 2016
by
Dragoș Tiselice
Committed by
GitHub
Sep 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced FlexDirection with Axis. (#5896)
Fixes #4618.
parent
4259266b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
60 deletions
+52
-60
flex_layout.dart
examples/layers/rendering/flex_layout.dart
+2
-2
spinning_mixed.dart
examples/layers/widgets/spinning_mixed.dart
+1
-1
flex.dart
packages/flutter/lib/src/rendering/flex.dart
+37
-45
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+5
-5
box_test.dart
packages/flutter/test/rendering/box_test.dart
+1
-1
flex_test.dart
packages/flutter/test/rendering/flex_test.dart
+6
-6
No files found.
examples/layers/rendering/flex_layout.dart
View file @
8ac14f86
...
@@ -10,7 +10,7 @@ import 'package:flutter/rendering.dart';
...
@@ -10,7 +10,7 @@ import 'package:flutter/rendering.dart';
import
'src/solid_color_box.dart'
;
import
'src/solid_color_box.dart'
;
void
main
(
)
{
void
main
(
)
{
RenderFlex
table
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
);
RenderFlex
table
=
new
RenderFlex
(
direction:
Axis
.
vertical
);
void
addAlignmentRow
(
CrossAxisAlignment
crossAxisAlignment
)
{
void
addAlignmentRow
(
CrossAxisAlignment
crossAxisAlignment
)
{
TextStyle
style
=
const
TextStyle
(
color:
const
Color
(
0xFF000000
));
TextStyle
style
=
const
TextStyle
(
color:
const
Color
(
0xFF000000
));
...
@@ -50,7 +50,7 @@ void main() {
...
@@ -50,7 +50,7 @@ void main() {
const
TextStyle
style
=
const
TextStyle
(
color:
const
Color
(
0xFF000000
));
const
TextStyle
style
=
const
TextStyle
(
color:
const
Color
(
0xFF000000
));
RenderParagraph
paragraph
=
new
RenderParagraph
(
new
TextSpan
(
style:
style
,
text:
'
$justify
'
));
RenderParagraph
paragraph
=
new
RenderParagraph
(
new
TextSpan
(
style:
style
,
text:
'
$justify
'
));
table
.
add
(
new
RenderPadding
(
child:
paragraph
,
padding:
new
EdgeInsets
.
only
(
top:
20.0
)));
table
.
add
(
new
RenderPadding
(
child:
paragraph
,
padding:
new
EdgeInsets
.
only
(
top:
20.0
)));
RenderFlex
row
=
new
RenderFlex
(
direction:
FlexDirection
.
horizontal
);
RenderFlex
row
=
new
RenderFlex
(
direction:
Axis
.
horizontal
);
row
.
add
(
new
RenderSolidColorBox
(
const
Color
(
0xFFFFCCCC
),
desiredSize:
new
Size
(
80.0
,
60.0
)));
row
.
add
(
new
RenderSolidColorBox
(
const
Color
(
0xFFFFCCCC
),
desiredSize:
new
Size
(
80.0
,
60.0
)));
row
.
add
(
new
RenderSolidColorBox
(
const
Color
(
0xFFCCFFCC
),
desiredSize:
new
Size
(
64.0
,
60.0
)));
row
.
add
(
new
RenderSolidColorBox
(
const
Color
(
0xFFCCFFCC
),
desiredSize:
new
Size
(
64.0
,
60.0
)));
row
.
add
(
new
RenderSolidColorBox
(
const
Color
(
0xFFCCCCFF
),
desiredSize:
new
Size
(
160.0
,
60.0
)));
row
.
add
(
new
RenderSolidColorBox
(
const
Color
(
0xFFCCCCFF
),
desiredSize:
new
Size
(
160.0
,
60.0
)));
...
...
examples/layers/widgets/spinning_mixed.dart
View file @
8ac14f86
...
@@ -93,7 +93,7 @@ void main() {
...
@@ -93,7 +93,7 @@ void main() {
RenderProxyBox
proxy
=
new
RenderProxyBox
();
RenderProxyBox
proxy
=
new
RenderProxyBox
();
attachWidgetTreeToRenderTree
(
proxy
);
attachWidgetTreeToRenderTree
(
proxy
);
RenderFlex
flexRoot
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
);
RenderFlex
flexRoot
=
new
RenderFlex
(
direction:
Axis
.
vertical
);
addFlexChildSolidColor
(
flexRoot
,
const
Color
(
0xFFFF00FF
),
flex:
1
);
addFlexChildSolidColor
(
flexRoot
,
const
Color
(
0xFFFF00FF
),
flex:
1
);
flexRoot
.
add
(
proxy
);
flexRoot
.
add
(
proxy
);
addFlexChildSolidColor
(
flexRoot
,
const
Color
(
0xFF0000FF
),
flex:
1
);
addFlexChildSolidColor
(
flexRoot
,
const
Color
(
0xFF0000FF
),
flex:
1
);
...
...
packages/flutter/lib/src/rendering/flex.dart
View file @
8ac14f86
...
@@ -21,14 +21,6 @@ class FlexParentData extends ContainerBoxParentDataMixin<RenderBox> {
...
@@ -21,14 +21,6 @@ class FlexParentData extends ContainerBoxParentDataMixin<RenderBox> {
String
toString
()
=>
'
${super.toString()}
; flex=
$flex
'
;
String
toString
()
=>
'
${super.toString()}
; flex=
$flex
'
;
}
}
/// The direction in which the box should flex
enum
FlexDirection
{
/// Children are arranged horizontally, from left to right
horizontal
,
/// Children are arranged vertically, from top to bottom
vertical
}
/// The incoming constraint parameter that defines how much space is available
/// The incoming constraint parameter that defines how much space is available
/// along the main axis in a flex layout. Flex layouts allocate the difference
/// along the main axis in a flex layout. Flex layouts allocate the difference
/// between the available space and the sum of the sizes of the children
/// between the available space and the sum of the sizes of the children
...
@@ -106,7 +98,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -106,7 +98,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
/// start of the main axis and the center of the cross axis.
/// start of the main axis and the center of the cross axis.
RenderFlex
({
RenderFlex
({
List
<
RenderBox
>
children
,
List
<
RenderBox
>
children
,
FlexDirection
direction:
FlexDirection
.
horizontal
,
Axis
direction:
Axis
.
horizontal
,
MainAxisSize
mainAxisSize:
MainAxisSize
.
max
,
MainAxisSize
mainAxisSize:
MainAxisSize
.
max
,
MainAxisAlignment
mainAxisAlignment:
MainAxisAlignment
.
start
,
MainAxisAlignment
mainAxisAlignment:
MainAxisAlignment
.
start
,
CrossAxisAlignment
crossAxisAlignment:
CrossAxisAlignment
.
center
,
CrossAxisAlignment
crossAxisAlignment:
CrossAxisAlignment
.
center
,
...
@@ -120,9 +112,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -120,9 +112,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
/// The direction to use as the main axis.
/// The direction to use as the main axis.
FlexDirection
get
direction
=>
_direction
;
Axis
get
direction
=>
_direction
;
FlexDirection
_direction
;
Axis
_direction
;
set
direction
(
FlexDirection
value
)
{
set
direction
(
Axis
value
)
{
if
(
_direction
!=
value
)
{
if
(
_direction
!=
value
)
{
_direction
=
value
;
_direction
=
value
;
markNeedsLayout
();
markNeedsLayout
();
...
@@ -180,7 +172,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -180,7 +172,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
double
_getIntrinsicSize
({
double
_getIntrinsicSize
({
FlexDirection
sizingDirection
,
Axis
sizingDirection
,
double
extent
,
// the extent in the direction that isn't the sizing direction
double
extent
,
// the extent in the direction that isn't the sizing direction
_ChildSizingFunction
childSize
// a method to find the size in the sizing direction
_ChildSizingFunction
childSize
// a method to find the size in the sizing direction
})
{
})
{
...
@@ -225,11 +217,11 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -225,11 +217,11 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
double
crossSize
;
double
crossSize
;
if
(
flex
==
0
)
{
if
(
flex
==
0
)
{
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
mainSize
=
child
.
getMaxIntrinsicWidth
(
double
.
INFINITY
);
mainSize
=
child
.
getMaxIntrinsicWidth
(
double
.
INFINITY
);
crossSize
=
childSize
(
child
,
mainSize
);
crossSize
=
childSize
(
child
,
mainSize
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
mainSize
=
child
.
getMaxIntrinsicHeight
(
double
.
INFINITY
);
mainSize
=
child
.
getMaxIntrinsicHeight
(
double
.
INFINITY
);
crossSize
=
childSize
(
child
,
mainSize
);
crossSize
=
childSize
(
child
,
mainSize
);
break
;
break
;
...
@@ -263,7 +255,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -263,7 +255,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
@override
@override
double
computeMinIntrinsicWidth
(
double
height
)
{
double
computeMinIntrinsicWidth
(
double
height
)
{
return
_getIntrinsicSize
(
return
_getIntrinsicSize
(
sizingDirection:
FlexDirection
.
horizontal
,
sizingDirection:
Axis
.
horizontal
,
extent:
height
,
extent:
height
,
childSize:
(
RenderBox
child
,
double
extent
)
=>
child
.
getMinIntrinsicWidth
(
extent
)
childSize:
(
RenderBox
child
,
double
extent
)
=>
child
.
getMinIntrinsicWidth
(
extent
)
);
);
...
@@ -272,7 +264,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -272,7 +264,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
@override
@override
double
computeMaxIntrinsicWidth
(
double
height
)
{
double
computeMaxIntrinsicWidth
(
double
height
)
{
return
_getIntrinsicSize
(
return
_getIntrinsicSize
(
sizingDirection:
FlexDirection
.
horizontal
,
sizingDirection:
Axis
.
horizontal
,
extent:
height
,
extent:
height
,
childSize:
(
RenderBox
child
,
double
extent
)
=>
child
.
getMaxIntrinsicWidth
(
extent
)
childSize:
(
RenderBox
child
,
double
extent
)
=>
child
.
getMaxIntrinsicWidth
(
extent
)
);
);
...
@@ -281,7 +273,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -281,7 +273,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
@override
@override
double
computeMinIntrinsicHeight
(
double
width
)
{
double
computeMinIntrinsicHeight
(
double
width
)
{
return
_getIntrinsicSize
(
return
_getIntrinsicSize
(
sizingDirection:
FlexDirection
.
vertical
,
sizingDirection:
Axis
.
vertical
,
extent:
width
,
extent:
width
,
childSize:
(
RenderBox
child
,
double
extent
)
=>
child
.
getMinIntrinsicHeight
(
extent
)
childSize:
(
RenderBox
child
,
double
extent
)
=>
child
.
getMinIntrinsicHeight
(
extent
)
);
);
...
@@ -290,7 +282,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -290,7 +282,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
@override
@override
double
computeMaxIntrinsicHeight
(
double
width
)
{
double
computeMaxIntrinsicHeight
(
double
width
)
{
return
_getIntrinsicSize
(
return
_getIntrinsicSize
(
sizingDirection:
FlexDirection
.
vertical
,
sizingDirection:
Axis
.
vertical
,
extent:
width
,
extent:
width
,
childSize:
(
RenderBox
child
,
double
extent
)
=>
child
.
getMaxIntrinsicHeight
(
extent
)
childSize:
(
RenderBox
child
,
double
extent
)
=>
child
.
getMaxIntrinsicHeight
(
extent
)
);
);
...
@@ -298,7 +290,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -298,7 +290,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
@override
@override
double
computeDistanceToActualBaseline
(
TextBaseline
baseline
)
{
double
computeDistanceToActualBaseline
(
TextBaseline
baseline
)
{
if
(
_direction
==
FlexDirection
.
horizontal
)
if
(
_direction
==
Axis
.
horizontal
)
return
defaultComputeDistanceToHighestActualBaseline
(
baseline
);
return
defaultComputeDistanceToHighestActualBaseline
(
baseline
);
return
defaultComputeDistanceToFirstActualBaseline
(
baseline
);
return
defaultComputeDistanceToFirstActualBaseline
(
baseline
);
}
}
...
@@ -309,11 +301,11 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -309,11 +301,11 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
double
_getCrossSize
(
RenderBox
child
)
{
double
_getCrossSize
(
RenderBox
child
)
{
return
(
_direction
==
FlexDirection
.
horizontal
)
?
child
.
size
.
height
:
child
.
size
.
width
;
return
(
_direction
==
Axis
.
horizontal
)
?
child
.
size
.
height
:
child
.
size
.
width
;
}
}
double
_getMainSize
(
RenderBox
child
)
{
double
_getMainSize
(
RenderBox
child
)
{
return
(
_direction
==
FlexDirection
.
horizontal
)
?
child
.
size
.
width
:
child
.
size
.
height
;
return
(
_direction
==
Axis
.
horizontal
)
?
child
.
size
.
width
:
child
.
size
.
height
;
}
}
@override
@override
...
@@ -322,7 +314,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -322,7 +314,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
int
totalFlex
=
0
;
int
totalFlex
=
0
;
int
totalChildren
=
0
;
int
totalChildren
=
0
;
assert
(
constraints
!=
null
);
assert
(
constraints
!=
null
);
final
bool
isHorizontal
=
_direction
==
FlexDirection
.
horizontal
;
final
bool
isHorizontal
=
_direction
==
Axis
.
horizontal
;
final
double
minMainSize
=
isHorizontal
?
constraints
.
minWidth
:
constraints
.
minHeight
;
final
double
minMainSize
=
isHorizontal
?
constraints
.
minWidth
:
constraints
.
minHeight
;
final
double
maxMainSize
=
isHorizontal
?
constraints
.
maxWidth
:
constraints
.
maxHeight
;
final
double
maxMainSize
=
isHorizontal
?
constraints
.
maxWidth
:
constraints
.
maxHeight
;
final
double
availableSize
=
mainAxisSize
==
MainAxisSize
.
max
?
maxMainSize
:
minMainSize
;
final
double
availableSize
=
mainAxisSize
==
MainAxisSize
.
max
?
maxMainSize
:
minMainSize
;
...
@@ -337,9 +329,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -337,9 +329,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
int
flex
=
_getFlex
(
child
);
int
flex
=
_getFlex
(
child
);
if
(
flex
>
0
)
{
if
(
flex
>
0
)
{
assert
(()
{
assert
(()
{
final
String
identity
=
_direction
==
FlexDirection
.
horizontal
?
'row'
:
'column'
;
final
String
identity
=
_direction
==
Axis
.
horizontal
?
'row'
:
'column'
;
final
String
axis
=
_direction
==
FlexDirection
.
horizontal
?
'horizontal'
:
'vertical'
;
final
String
axis
=
_direction
==
Axis
.
horizontal
?
'horizontal'
:
'vertical'
;
final
String
dimension
=
_direction
==
FlexDirection
.
horizontal
?
'width'
:
'height'
;
final
String
dimension
=
_direction
==
Axis
.
horizontal
?
'width'
:
'height'
;
String
error
,
message
;
String
error
,
message
;
String
addendum
=
''
;
String
addendum
=
''
;
if
(
availableSize
==
double
.
INFINITY
)
{
if
(
availableSize
==
double
.
INFINITY
)
{
...
@@ -351,13 +343,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -351,13 +343,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
StringBuffer
information
=
new
StringBuffer
();
StringBuffer
information
=
new
StringBuffer
();
RenderBox
node
=
this
;
RenderBox
node
=
this
;
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
while
(!
node
.
constraints
.
hasBoundedWidth
&&
node
.
parent
is
RenderBox
)
while
(!
node
.
constraints
.
hasBoundedWidth
&&
node
.
parent
is
RenderBox
)
node
=
node
.
parent
;
node
=
node
.
parent
;
if
(!
node
.
constraints
.
hasBoundedWidth
)
if
(!
node
.
constraints
.
hasBoundedWidth
)
node
=
null
;
node
=
null
;
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
while
(!
node
.
constraints
.
hasBoundedHeight
&&
node
.
parent
is
RenderBox
)
while
(!
node
.
constraints
.
hasBoundedHeight
&&
node
.
parent
is
RenderBox
)
node
=
node
.
parent
;
node
=
node
.
parent
;
if
(!
node
.
constraints
.
hasBoundedHeight
)
if
(!
node
.
constraints
.
hasBoundedHeight
)
...
@@ -399,21 +391,21 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -399,21 +391,21 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
BoxConstraints
innerConstraints
;
BoxConstraints
innerConstraints
;
if
(
crossAxisAlignment
==
CrossAxisAlignment
.
stretch
)
{
if
(
crossAxisAlignment
==
CrossAxisAlignment
.
stretch
)
{
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
innerConstraints
=
new
BoxConstraints
(
minHeight:
constraints
.
maxHeight
,
innerConstraints
=
new
BoxConstraints
(
minHeight:
constraints
.
maxHeight
,
maxHeight:
constraints
.
maxHeight
);
maxHeight:
constraints
.
maxHeight
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
innerConstraints
=
new
BoxConstraints
(
minWidth:
constraints
.
maxWidth
,
innerConstraints
=
new
BoxConstraints
(
minWidth:
constraints
.
maxWidth
,
maxWidth:
constraints
.
maxWidth
);
maxWidth:
constraints
.
maxWidth
);
break
;
break
;
}
}
}
else
{
}
else
{
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
innerConstraints
=
new
BoxConstraints
(
maxHeight:
constraints
.
maxHeight
);
innerConstraints
=
new
BoxConstraints
(
maxHeight:
constraints
.
maxHeight
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
innerConstraints
=
new
BoxConstraints
(
maxWidth:
constraints
.
maxWidth
);
innerConstraints
=
new
BoxConstraints
(
maxWidth:
constraints
.
maxWidth
);
break
;
break
;
}
}
...
@@ -441,13 +433,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -441,13 +433,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
BoxConstraints
innerConstraints
;
BoxConstraints
innerConstraints
;
if
(
crossAxisAlignment
==
CrossAxisAlignment
.
stretch
)
{
if
(
crossAxisAlignment
==
CrossAxisAlignment
.
stretch
)
{
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
innerConstraints
=
new
BoxConstraints
(
minWidth:
spaceForChild
,
innerConstraints
=
new
BoxConstraints
(
minWidth:
spaceForChild
,
maxWidth:
spaceForChild
,
maxWidth:
spaceForChild
,
minHeight:
constraints
.
maxHeight
,
minHeight:
constraints
.
maxHeight
,
maxHeight:
constraints
.
maxHeight
);
maxHeight:
constraints
.
maxHeight
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
innerConstraints
=
new
BoxConstraints
(
minWidth:
constraints
.
maxWidth
,
innerConstraints
=
new
BoxConstraints
(
minWidth:
constraints
.
maxWidth
,
maxWidth:
constraints
.
maxWidth
,
maxWidth:
constraints
.
maxWidth
,
minHeight:
spaceForChild
,
minHeight:
spaceForChild
,
...
@@ -456,12 +448,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -456,12 +448,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
}
else
{
}
else
{
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
innerConstraints
=
new
BoxConstraints
(
minWidth:
spaceForChild
,
innerConstraints
=
new
BoxConstraints
(
minWidth:
spaceForChild
,
maxWidth:
spaceForChild
,
maxWidth:
spaceForChild
,
maxHeight:
constraints
.
maxHeight
);
maxHeight:
constraints
.
maxHeight
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
innerConstraints
=
new
BoxConstraints
(
maxWidth:
constraints
.
maxWidth
,
innerConstraints
=
new
BoxConstraints
(
maxWidth:
constraints
.
maxWidth
,
minHeight:
spaceForChild
,
minHeight:
spaceForChild
,
maxHeight:
spaceForChild
);
maxHeight:
spaceForChild
);
...
@@ -496,12 +488,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -496,12 +488,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
final
double
preferredSize
=
isMainAxisSizeMax
?
maxMainSize
:
allocatedSize
;
final
double
preferredSize
=
isMainAxisSizeMax
?
maxMainSize
:
allocatedSize
;
remainingSpace
=
math
.
max
(
0.0
,
freeSpace
-
usedSpace
);
remainingSpace
=
math
.
max
(
0.0
,
freeSpace
-
usedSpace
);
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
size
=
constraints
.
constrain
(
new
Size
(
preferredSize
,
crossSize
));
size
=
constraints
.
constrain
(
new
Size
(
preferredSize
,
crossSize
));
crossSize
=
size
.
height
;
crossSize
=
size
.
height
;
assert
(
isMainAxisSizeMax
?
size
.
width
==
maxMainSize
:
size
.
width
>=
minMainSize
);
assert
(
isMainAxisSizeMax
?
size
.
width
==
maxMainSize
:
size
.
width
>=
minMainSize
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
size
=
constraints
.
constrain
(
new
Size
(
crossSize
,
preferredSize
));
size
=
constraints
.
constrain
(
new
Size
(
crossSize
,
preferredSize
));
crossSize
=
size
.
width
;
crossSize
=
size
.
width
;
assert
(
isMainAxisSizeMax
?
size
.
height
==
maxMainSize
:
size
.
height
>=
minMainSize
);
assert
(
isMainAxisSizeMax
?
size
.
height
==
maxMainSize
:
size
.
height
>=
minMainSize
);
...
@@ -512,12 +504,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -512,12 +504,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
leadingSpace
=
0.0
;
leadingSpace
=
0.0
;
betweenSpace
=
0.0
;
betweenSpace
=
0.0
;
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
size
=
constraints
.
constrain
(
new
Size
(
_overflow
,
crossSize
));
size
=
constraints
.
constrain
(
new
Size
(
_overflow
,
crossSize
));
crossSize
=
size
.
height
;
crossSize
=
size
.
height
;
remainingSpace
=
math
.
max
(
0.0
,
size
.
width
-
_overflow
);
remainingSpace
=
math
.
max
(
0.0
,
size
.
width
-
_overflow
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
size
=
constraints
.
constrain
(
new
Size
(
crossSize
,
_overflow
));
size
=
constraints
.
constrain
(
new
Size
(
crossSize
,
_overflow
));
crossSize
=
size
.
width
;
crossSize
=
size
.
width
;
remainingSpace
=
math
.
max
(
0.0
,
size
.
height
-
_overflow
);
remainingSpace
=
math
.
max
(
0.0
,
size
.
height
-
_overflow
);
...
@@ -571,7 +563,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -571,7 +563,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
break
;
break
;
case
CrossAxisAlignment
.
baseline
:
case
CrossAxisAlignment
.
baseline
:
childCrossPosition
=
0.0
;
childCrossPosition
=
0.0
;
if
(
_direction
==
FlexDirection
.
horizontal
)
{
if
(
_direction
==
Axis
.
horizontal
)
{
assert
(
textBaseline
!=
null
);
assert
(
textBaseline
!=
null
);
double
distance
=
child
.
getDistanceToBaseline
(
textBaseline
,
onlyReal:
true
);
double
distance
=
child
.
getDistanceToBaseline
(
textBaseline
,
onlyReal:
true
);
if
(
distance
!=
null
)
if
(
distance
!=
null
)
...
@@ -580,10 +572,10 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -580,10 +572,10 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
break
;
break
;
}
}
switch
(
_direction
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
childParentData
.
offset
=
new
Offset
(
childMainPosition
,
childCrossPosition
);
childParentData
.
offset
=
new
Offset
(
childMainPosition
,
childCrossPosition
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
childParentData
.
offset
=
new
Offset
(
childCrossPosition
,
childMainPosition
);
childParentData
.
offset
=
new
Offset
(
childCrossPosition
,
childMainPosition
);
break
;
break
;
}
}
...
@@ -621,13 +613,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
...
@@ -621,13 +613,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
const
double
kMarkerSize
=
0.1
;
const
double
kMarkerSize
=
0.1
;
Rect
markerRect
,
overflowRect
;
Rect
markerRect
,
overflowRect
;
switch
(
direction
)
{
switch
(
direction
)
{
case
FlexDirection
.
horizontal
:
case
Axis
.
horizontal
:
markerRect
=
offset
+
new
Offset
(
size
.
width
*
(
1.0
-
kMarkerSize
),
0.0
)
&
markerRect
=
offset
+
new
Offset
(
size
.
width
*
(
1.0
-
kMarkerSize
),
0.0
)
&
new
Size
(
size
.
width
*
kMarkerSize
,
size
.
height
);
new
Size
(
size
.
width
*
kMarkerSize
,
size
.
height
);
overflowRect
=
offset
+
new
Offset
(
size
.
width
,
0.0
)
&
overflowRect
=
offset
+
new
Offset
(
size
.
width
,
0.0
)
&
new
Size
(
_overflow
,
size
.
height
);
new
Size
(
_overflow
,
size
.
height
);
break
;
break
;
case
FlexDirection
.
vertical
:
case
Axis
.
vertical
:
markerRect
=
offset
+
new
Offset
(
0.0
,
size
.
height
*
(
1.0
-
kMarkerSize
))
&
markerRect
=
offset
+
new
Offset
(
0.0
,
size
.
height
*
(
1.0
-
kMarkerSize
))
&
new
Size
(
size
.
width
,
size
.
height
*
kMarkerSize
);
new
Size
(
size
.
width
,
size
.
height
*
kMarkerSize
);
overflowRect
=
offset
+
new
Offset
(
0.0
,
size
.
height
)
&
overflowRect
=
offset
+
new
Offset
(
0.0
,
size
.
height
)
&
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
8ac14f86
...
@@ -20,7 +20,7 @@ export 'package:flutter/rendering.dart' show
...
@@ -20,7 +20,7 @@ export 'package:flutter/rendering.dart' show
CustomClipper
,
CustomClipper
,
CustomPainter
,
CustomPainter
,
FixedColumnCountGridDelegate
,
FixedColumnCountGridDelegate
,
FlexDirection
,
Axis
,
FlowDelegate
,
FlowDelegate
,
FlowPaintingContext
,
FlowPaintingContext
,
FractionalOffsetTween
,
FractionalOffsetTween
,
...
@@ -1823,7 +1823,7 @@ class Flex extends MultiChildRenderObjectWidget {
...
@@ -1823,7 +1823,7 @@ class Flex extends MultiChildRenderObjectWidget {
/// [CrossAxisAlignment.baseline], then [textBaseline] must not be null.
/// [CrossAxisAlignment.baseline], then [textBaseline] must not be null.
Flex
({
Flex
({
Key
key
,
Key
key
,
this
.
direction
:
FlexDirection
.
horizontal
,
this
.
direction
:
Axis
.
horizontal
,
this
.
mainAxisAlignment
:
MainAxisAlignment
.
start
,
this
.
mainAxisAlignment
:
MainAxisAlignment
.
start
,
this
.
mainAxisSize
:
MainAxisSize
.
max
,
this
.
mainAxisSize
:
MainAxisSize
.
max
,
this
.
crossAxisAlignment
:
CrossAxisAlignment
.
center
,
this
.
crossAxisAlignment
:
CrossAxisAlignment
.
center
,
...
@@ -1838,7 +1838,7 @@ class Flex extends MultiChildRenderObjectWidget {
...
@@ -1838,7 +1838,7 @@ class Flex extends MultiChildRenderObjectWidget {
}
}
/// The direction to use as the main axis.
/// The direction to use as the main axis.
final
FlexDirection
direction
;
final
Axis
direction
;
/// How the children should be placed along the main axis.
/// How the children should be placed along the main axis.
final
MainAxisAlignment
mainAxisAlignment
;
final
MainAxisAlignment
mainAxisAlignment
;
...
@@ -1902,7 +1902,7 @@ class Row extends Flex {
...
@@ -1902,7 +1902,7 @@ class Row extends Flex {
})
:
super
(
})
:
super
(
children:
children
,
children:
children
,
key:
key
,
key:
key
,
direction:
FlexDirection
.
horizontal
,
direction:
Axis
.
horizontal
,
mainAxisAlignment:
mainAxisAlignment
,
mainAxisAlignment:
mainAxisAlignment
,
mainAxisSize:
mainAxisSize
,
mainAxisSize:
mainAxisSize
,
crossAxisAlignment:
crossAxisAlignment
,
crossAxisAlignment:
crossAxisAlignment
,
...
@@ -1930,7 +1930,7 @@ class Column extends Flex {
...
@@ -1930,7 +1930,7 @@ class Column extends Flex {
})
:
super
(
})
:
super
(
children:
children
,
children:
children
,
key:
key
,
key:
key
,
direction:
FlexDirection
.
vertical
,
direction:
Axis
.
vertical
,
mainAxisAlignment:
mainAxisAlignment
,
mainAxisAlignment:
mainAxisAlignment
,
mainAxisSize:
mainAxisSize
,
mainAxisSize:
mainAxisSize
,
crossAxisAlignment:
crossAxisAlignment
,
crossAxisAlignment:
crossAxisAlignment
,
...
...
packages/flutter/test/rendering/box_test.dart
View file @
8ac14f86
...
@@ -39,7 +39,7 @@ void main() {
...
@@ -39,7 +39,7 @@ void main() {
);
);
RenderBox
flex
=
new
RenderFlex
(
RenderBox
flex
=
new
RenderFlex
(
children:
<
RenderBox
>[
padding
],
children:
<
RenderBox
>[
padding
],
direction:
FlexDirection
.
vertical
,
direction:
Axis
.
vertical
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
crossAxisAlignment:
CrossAxisAlignment
.
stretch
);
);
RenderBox
outer
=
new
RenderDecoratedBox
(
RenderBox
outer
=
new
RenderDecoratedBox
(
...
...
packages/flutter/test/rendering/flex_test.dart
View file @
8ac14f86
...
@@ -24,7 +24,7 @@ void main() {
...
@@ -24,7 +24,7 @@ void main() {
additionalConstraints:
const
BoxConstraints
.
expand
()
additionalConstraints:
const
BoxConstraints
.
expand
()
);
);
RenderFlex
flex
=
new
RenderFlex
(
RenderFlex
flex
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
,
direction:
Axis
.
vertical
,
children:
<
RenderBox
>[
children:
<
RenderBox
>[
new
RenderConstrainedBox
(
additionalConstraints:
new
BoxConstraints
.
tightFor
(
height:
200.0
)),
new
RenderConstrainedBox
(
additionalConstraints:
new
BoxConstraints
.
tightFor
(
height:
200.0
)),
flexible
,
flexible
,
...
@@ -46,7 +46,7 @@ void main() {
...
@@ -46,7 +46,7 @@ void main() {
additionalConstraints:
const
BoxConstraints
.
expand
()
additionalConstraints:
const
BoxConstraints
.
expand
()
);
);
RenderFlex
flex
=
new
RenderFlex
(
RenderFlex
flex
=
new
RenderFlex
(
direction:
FlexDirection
.
horizontal
,
direction:
Axis
.
horizontal
,
children:
<
RenderBox
>[
children:
<
RenderBox
>[
new
RenderConstrainedBox
(
additionalConstraints:
new
BoxConstraints
.
tightFor
(
width:
200.0
)),
new
RenderConstrainedBox
(
additionalConstraints:
new
BoxConstraints
.
tightFor
(
width:
200.0
)),
flexible
,
flexible
,
...
@@ -65,7 +65,7 @@ void main() {
...
@@ -65,7 +65,7 @@ void main() {
test
(
'Vertical Flipped Constraints'
,
()
{
test
(
'Vertical Flipped Constraints'
,
()
{
RenderFlex
flex
=
new
RenderFlex
(
RenderFlex
flex
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
,
direction:
Axis
.
vertical
,
children:
<
RenderBox
>[
children:
<
RenderBox
>[
new
RenderAspectRatio
(
aspectRatio:
1.0
),
new
RenderAspectRatio
(
aspectRatio:
1.0
),
]
]
...
@@ -81,7 +81,7 @@ void main() {
...
@@ -81,7 +81,7 @@ void main() {
test
(
'Defaults'
,
()
{
test
(
'Defaults'
,
()
{
RenderFlex
flex
=
new
RenderFlex
();
RenderFlex
flex
=
new
RenderFlex
();
expect
(
flex
.
crossAxisAlignment
,
equals
(
CrossAxisAlignment
.
center
));
expect
(
flex
.
crossAxisAlignment
,
equals
(
CrossAxisAlignment
.
center
));
expect
(
flex
.
direction
,
equals
(
FlexDirection
.
horizontal
));
expect
(
flex
.
direction
,
equals
(
Axis
.
horizontal
));
});
});
test
(
'Parent data'
,
()
{
test
(
'Parent data'
,
()
{
...
@@ -129,7 +129,7 @@ void main() {
...
@@ -129,7 +129,7 @@ void main() {
expect
(
box2
.
size
.
width
,
equals
(
100.0
));
expect
(
box2
.
size
.
width
,
equals
(
100.0
));
expect
(
box2
.
size
.
height
,
equals
(
100.0
));
expect
(
box2
.
size
.
height
,
equals
(
100.0
));
flex
.
direction
=
FlexDirection
.
vertical
;
flex
.
direction
=
Axis
.
vertical
;
pumpFrame
();
pumpFrame
();
expect
(
box1
.
size
.
width
,
equals
(
100.0
));
expect
(
box1
.
size
.
width
,
equals
(
100.0
));
expect
(
box1
.
size
.
height
,
equals
(
0.0
));
expect
(
box1
.
size
.
height
,
equals
(
0.0
));
...
@@ -157,7 +157,7 @@ void main() {
...
@@ -157,7 +157,7 @@ void main() {
expect
(
getOffset
(
box3
).
dx
,
equals
(
350.0
));
expect
(
getOffset
(
box3
).
dx
,
equals
(
350.0
));
expect
(
box3
.
size
.
width
,
equals
(
100.0
));
expect
(
box3
.
size
.
width
,
equals
(
100.0
));
flex
.
direction
=
FlexDirection
.
vertical
;
flex
.
direction
=
Axis
.
vertical
;
pumpFrame
();
pumpFrame
();
expect
(
getOffset
(
box1
).
dy
,
equals
(
25.0
));
expect
(
getOffset
(
box1
).
dy
,
equals
(
25.0
));
expect
(
box1
.
size
.
height
,
equals
(
100.0
));
expect
(
box1
.
size
.
height
,
equals
(
100.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