0

请在此处输入图像描述我需要删除容器小部件并将边框半径添加到文本小部件,或者是否可以使文本小部件和容器小部件一起响应更改(意思是:当文本为空时容器应该' t 显示)

   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,
                                      ),
                                    )),
4

1 回答 1

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,
              ),
            ),
          );
  }
于 2020-04-27T02:49:47.850 回答