enter image description here,请删除容器窗口小部件并向文本窗口小部件添加边框半径,或者是否可以使文本窗口小部件和容器窗口小部件共同响应更改(意味着:当文本为空时该容器不应显示)
child: Container(
padding: EdgeInsets.fromLTRB(25.0, 0, 10.0, 0),
decoration: ShapeDecoration(
color: Colors.grey[850],
shape: RoundedRectangleBorder(
side: BorderSide(
width: 2.0,
style: BorderStyle.solid,
color: Colors.black,
),
borderRadius:
BorderRadius.all(Radius.circular(15.0)),
),
),
child: Text(
costOfSales,
style: TextStyle(
`enter code here` color: Colors.white,
fontSize: 25.0,
),
)),
答案 0 :(得分:0)
Widget build(BuildContext context) {
var costOfSales = "\$99";
return costOfSales == null
? Container()
: Container(
padding: EdgeInsets.fromLTRB(25.0, 0, 10.0, 0),
decoration: ShapeDecoration(
color: Colors.grey[850],
shape: RoundedRectangleBorder(
side: BorderSide(
width: 2.0,
style: BorderStyle.solid,
color: Colors.black,
),
borderRadius: BorderRadius.all(Radius.circular(15.0)),
),
),
child: Text(
costOfSales,
style: TextStyle(
color: Colors.white,
fontSize: 25.0,
),
),
);
}