Commit 944d2ef6 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Revert "Size of a childless container's implicit DecoratedBox descendants" (#6663)

parent abcfc42d
......@@ -166,15 +166,13 @@ class Container extends StatelessWidget {
);
}
if (alignment != null)
current = new Align(alignment: alignment, child: current);
EdgeInsets effectivePadding = _paddingIncludingDecoration;
if (effectivePadding != null)
current = new Padding(padding: effectivePadding, child: current);
// If a child was specified then align it - but not the implicit
// DecoratedBox descendants - within this container.
if (alignment != null && child != null)
current = new Align(alignment: alignment, child: current);
if (decoration != null)
current = new DecoratedBox(decoration: decoration, child: current);
......@@ -195,11 +193,6 @@ class Container extends StatelessWidget {
if (transform != null)
current = new Transform(transform: transform, child: current);
// If no child was specified then align the implicit DecoratedBox
// descendants, if any.
if (alignment != null && child == null)
current = new Align(alignment: alignment, child: current);
return current;
}
......
......@@ -9,170 +9,4 @@ void main() {
testWidgets('Can be placed in an infinite box', (WidgetTester tester) async {
await tester.pumpWidget(new Block(children: <Widget>[new Container()]));
});
testWidgets('Size of a container within an align', (WidgetTester tester) async {
GlobalKey innerContainerKey = new GlobalKey();
await tester.pumpWidget(
new Center(
child: new SizedBox(
width: 300.0,
height: 400.0,
child: new Align(
alignment:FractionalOffset.topLeft,
child: new Container(
key: innerContainerKey,
width: 50.0,
height: 100.0,
),
),
),
),
);
final Size size = innerContainerKey.currentContext.size;
expect(size.width, equals(50.0));
expect(size.height, equals(100.0));
});
testWidgets('Size of an aligned container\'s implicit child', (WidgetTester tester) async {
GlobalKey innerContainerKey = new GlobalKey();
await tester.pumpWidget(
new Center(
child: new SizedBox(
width: 300.0,
height: 400.0,
child: new Container(
key: innerContainerKey,
width: 50.0,
height: 100.0,
alignment:FractionalOffset.topLeft,
decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FF00)),
),
),
),
);
final Size size = innerContainerKey.currentContext.size;
expect(size.width, equals(300.0));
expect(size.height, equals(400.0));
RenderBox box = tester.renderObject(find.byType(DecoratedBox));
expect(box.size.width, equals(50.0));
expect(box.size.height, equals(100.0));
});
testWidgets('Position of an aligned and transformed container\'s implicit child', (WidgetTester tester) async {
GlobalKey innerContainerKey = new GlobalKey();
await tester.pumpWidget(
new Center(
child: new SizedBox(
width: 300.0,
height: 400.0,
child: new Container(
key: innerContainerKey,
width: 50.0,
height: 100.0,
alignment:FractionalOffset.topLeft,
decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FF00)),
transform: new Matrix4.identity()..translate(100.0, 200.0),
),
),
),
);
final Size size = innerContainerKey.currentContext.size;
expect(size.width, equals(300.0));
expect(size.height, equals(400.0));
RenderBox decoratedBox = tester.renderObject(find.byType(DecoratedBox));
expect(decoratedBox.size.width, equals(50.0));
expect(decoratedBox.size.height, equals(100.0));
RenderBox containerBox = innerContainerKey.currentContext.findRenderObject();
Point decoratedBoxOrigin = containerBox.globalToLocal(decoratedBox.localToGlobal(Point.origin));
expect(decoratedBoxOrigin.x, equals(100.0));
expect(decoratedBoxOrigin.y, equals(200.0));
});
testWidgets('Position of an aligned and transformed container\'s implicit children', (WidgetTester tester) async {
GlobalKey innerContainerKey = new GlobalKey();
await tester.pumpWidget(
new Center(
child: new SizedBox(
width: 300.0,
height: 400.0,
child: new Container(
key: innerContainerKey,
width: 50.0,
height: 100.0,
alignment:FractionalOffset.topLeft,
decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FF00)),
foregroundDecoration: new BoxDecoration(backgroundColor: const Color(0xFFFF0000)),
transform: new Matrix4.identity()..translate(100.0, 200.0),
),
),
),
);
final Size size = innerContainerKey.currentContext.size;
expect(size.width, equals(300.0));
expect(size.height, equals(400.0));
RenderBox containerBox = innerContainerKey.currentContext.findRenderObject();
List<RenderObject> renderers = tester.renderObjectList(find.byType(DecoratedBox)).toList();
expect(renderers.length, equals(2));
for (RenderObject renderer in renderers) {
RenderBox decoratedBox = renderer;
expect(decoratedBox.size.width, equals(50.0));
expect(decoratedBox.size.height, equals(100.0));
Point decoratedBoxOrigin = containerBox.globalToLocal(decoratedBox.localToGlobal(Point.origin));
expect(decoratedBoxOrigin.x, equals(100.0));
expect(decoratedBoxOrigin.y, equals(200.0));
}
});
testWidgets('Position of an aligned container\'s implicit children with margins', (WidgetTester tester) async {
GlobalKey innerContainerKey = new GlobalKey();
await tester.pumpWidget(
new Center(
child: new SizedBox(
width: 300.0,
height: 400.0,
child: new Container(
key: innerContainerKey,
width: 50.0,
height: 100.0,
alignment:FractionalOffset.topLeft,
decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FF00)),
foregroundDecoration: new BoxDecoration(backgroundColor: const Color(0xFFFF0000)),
margin: const EdgeInsets.only(left: 25.0, top: 75.0),
),
),
),
);
final Size size = innerContainerKey.currentContext.size;
expect(size.width, equals(300.0));
expect(size.height, equals(400.0));
RenderBox containerBox = innerContainerKey.currentContext.findRenderObject();
List<RenderObject> renderers = tester.renderObjectList(find.byType(DecoratedBox)).toList();
expect(renderers.length, equals(2));
for (RenderObject renderer in renderers) {
RenderBox decoratedBox = renderer;
expect(decoratedBox.size.width, equals(50.0));
expect(decoratedBox.size.height, equals(100.0));
Point decoratedBoxOrigin = containerBox.globalToLocal(decoratedBox.localToGlobal(Point.origin));
expect(decoratedBoxOrigin.x, equals(25.0));
expect(decoratedBoxOrigin.y, equals(75.0));
}
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment