Merge pull request #1041 from abarth/overconstrainted_flex
RenderFlex should handle overconstrainted constraints
This commit is contained in:
@@ -295,7 +295,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 double mainSize = (_direction == FlexDirection.horizontal) ? constraints.maxWidth : constraints.maxHeight;
|
final double mainSize = (_direction == FlexDirection.horizontal) ? constraints.constrainWidth() : constraints.constrainHeight();
|
||||||
final bool canFlex = mainSize < double.INFINITY;
|
final bool canFlex = mainSize < double.INFINITY;
|
||||||
double crossSize = 0.0; // This is determined as we lay out the children
|
double crossSize = 0.0; // This is determined as we lay out the children
|
||||||
double freeSpace = canFlex ? mainSize : 0.0;
|
double freeSpace = canFlex ? mainSize : 0.0;
|
||||||
|
|||||||
16
packages/unit/test/rendering/flex_test.dart
Normal file
16
packages/unit/test/rendering/flex_test.dart
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import 'package:sky/rendering.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
import 'rendering_tester.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Overconstrained flex', () {
|
||||||
|
RenderDecoratedBox box = new RenderDecoratedBox(decoration: new BoxDecoration());
|
||||||
|
RenderFlex flex = new RenderFlex(children: [ box ]);
|
||||||
|
layout(flex, constraints: const BoxConstraints(
|
||||||
|
minWidth: 200.0, maxWidth: 100.0, minHeight: 200.0, maxHeight: 100.0));
|
||||||
|
|
||||||
|
expect(flex.size.width, equals(200.0), reason: "flex width");
|
||||||
|
expect(flex.size.height, equals(200.0), reason: "flex height");
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user