官网提到
Containers with no children try to be as big as possible unless the incoming constraints are unbounded, in which case they try to be as small as possible.
意思是如果没有子元素, 并且给的constraints
是unbounded
的, 那么Container
就会尽可能的小.
但是测试下来似乎不是这样的, 不知道是不是理解有误
body: Container(
color: Colors.blueAccent,
constraints: BoxConstraints(maxHeight: double.infinity, maxWidth: double.infinity),
child: Container(
color: Colors.redAccent,
),
),
上面是代码, 蓝色Container里面套了一层红色Container. 外层Container给了unbounded的constraints, 但是内层的Container任然是铺满了外层的Container.
这个是为什么? 或者说, BoxConstraints(maxHeight: double.infinity, maxWidth: double.infinity),并不是unbounded
的?