Material (
海拔: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),
),
],
),
),
);
在上面的代码中,下面的这个小部件是堆栈的成员,我无法根据父级设置宽度。通常,我会在 flutter 中设置match_parent属性。
我应用了SizedBox.extend解决方案。该解决方案对我不起作用。
定位(
左:30,
子代:容器(
padding: EdgeInsets.only(
left: 50
),
height: 80,
color: Colors.black12,
child: Text("From : " + bills[index].fromDate.toString() + ""
"to : " + bills[index].toDate.toString()),
),
),
请帮帮我。提前致谢。
最佳答案
你可以试试:
Positioned(
left: 30,
right: 0,
child: Container(
/* your widget */
)
)
关于android - 如何根据Flutter Widget中的括号设置宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61430204/