[英]How to set width according to parends in Flutter Widget
Material( elevation: 0,材料(海拔:0,
child:
Container(
margin: const EdgeInsets.only(
bottom: 10
),
child: Stack(
children: <Widget>[
Positioned(
left: 30,
child: Container(
padding: EdgeInsets.only(
left: 50
),
height: 80,
color: Colors.black12,
child: Text("From : " + bills[index].fromDate.toString() + ""
"to : " + bills[index].toDate.toString()),
),
),
Container(
width: 80.0,
height: 80.0,
decoration: new BoxDecoration(
color: Colors.orange,
shape: BoxShape.circle,
),
),
Positioned(
top: 20,
left: 10,
child: Text(bills[index].bill.toString() + bills[index].currency),
),
],
),
),
);
In the above code, this widget below is a member of the stack and I could not set width according to the parents.在上面的代码中,下面的这个小部件是堆栈的成员,我无法根据父母设置宽度。 usually, I suffer setting match_parent attribute in a flutter.通常,我会在 flutter 中设置 match_parent 属性。 I apply SizedBox.extend solution.我应用 SizedBox.extend 解决方案。 the solution doesn't work for me.该解决方案对我不起作用。
Positioned( left: 30, child: Container(定位(左:30,子:容器(
padding: EdgeInsets.only(
left: 50
),
height: 80,
color: Colors.black12,
child: Text("From : " + bills[index].fromDate.toString() + ""
"to : " + bills[index].toDate.toString()),
),
),
Please help me out.请帮帮我。 thanks in advance.提前致谢。
You can try:你可以试试:
Positioned(
left: 30,
right: 0,
child: Container(
/* your widget */
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.