如何在Flutter中的图标上写文本

时间:2019-03-01 12:34:16

标签: dart flutter

enter image description here

我正在使用这段代码:如何在Flutter中设置这种布局

Container(
      height: 200.0,
      decoration: new BoxDecoration(
        color: Colors.white,
        shape: BoxShape.circle,
      ),
      child: Center(
        child: Stack(
          children: <Widget>[
            Icon(Icons.play_arrow, color: Colors.blue, size: 200.0,)
          ],
        ),
      ),

    );

1 个答案:

答案 0 :(得分:3)

尝试此操作,您只需要使Stack对准中心并在Text数组中添加Stack

Container(
      height: 200.0,
      decoration: new BoxDecoration(
        color: Colors.white,
        shape: BoxShape.circle,
      ),
      child: Center(
        child: Stack(
          alignment: Alignment.center,
          children: <Widget>[
            Icon(
              Icons.play_arrow,
              color: Colors.blue,
              size: 200.0,
            ),
            Text(
              "Play",
              style: TextStyle(fontSize: 18,color: Colors.white),
            ),
          ],
        ),
      ),
    )