【发布时间】:2018-12-05 19:12:29
【问题描述】:
在这段代码中,我尝试在 Stack 小部件中绘制一个 Text 小部件。但是,堆栈小部件不会根据定位的小部件调整自身大小,因此文本会被截断。
如何定位文本同时仍会影响 Stack 的大小?
return Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(height:20, width: 20, color: Colors.green,),
Positioned(
top: 10,
child: Text('Does not render because the stack is only 20x20'),
)
],
),
Container(height:40, width: 40, color: Colors.red,)
],
);
【问题讨论】: