mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1041 from abarth/overconstrainted_flex
RenderFlex should handle overconstrainted constraints
This commit is contained in:
commit
c2ee2db555
@ -295,7 +295,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
||||
int totalFlex = 0;
|
||||
int totalChildren = 0;
|
||||
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;
|
||||
double crossSize = 0.0; // This is determined as we lay out the children
|
||||
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");
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user