Implement 'stretch' for flexible items.
This commit is contained in:
parent
3784201b9f
commit
2c44ed0f01
@ -341,6 +341,22 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
|||||||
if (flex > 0) {
|
if (flex > 0) {
|
||||||
double spaceForChild = spacePerFlex * flex;
|
double spaceForChild = spacePerFlex * flex;
|
||||||
BoxConstraints innerConstraints;
|
BoxConstraints innerConstraints;
|
||||||
|
if (alignItems == FlexAlignItems.stretch) {
|
||||||
|
switch (_direction) {
|
||||||
|
case FlexDirection.horizontal:
|
||||||
|
innerConstraints = new BoxConstraints(minWidth: constraints.maxWidth,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
|
minHeight: constraints.minHeight,
|
||||||
|
maxHeight: constraints.maxHeight);
|
||||||
|
break;
|
||||||
|
case FlexDirection.vertical:
|
||||||
|
innerConstraints = new BoxConstraints(minWidth: constraints.minWidth,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
|
minHeight: constraints.maxHeight,
|
||||||
|
maxHeight: constraints.maxHeight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
switch (_direction) {
|
switch (_direction) {
|
||||||
case FlexDirection.horizontal:
|
case FlexDirection.horizontal:
|
||||||
innerConstraints = new BoxConstraints(maxHeight: constraints.maxHeight,
|
innerConstraints = new BoxConstraints(maxHeight: constraints.maxHeight,
|
||||||
@ -353,6 +369,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
|||||||
maxWidth: constraints.maxWidth);
|
maxWidth: constraints.maxWidth);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
child.layout(innerConstraints, parentUsesSize: true);
|
child.layout(innerConstraints, parentUsesSize: true);
|
||||||
usedSpace += _getMainSize(child);
|
usedSpace += _getMainSize(child);
|
||||||
crossSize = math.max(crossSize, _getCrossSize(child));
|
crossSize = math.max(crossSize, _getCrossSize(child));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user