颤动图标未在容器中居中

A.K*_*.94 0 flutter flutter-container flutter-widget

我试图将图标置于圆形背景的中心,但即使我使用中心小部件作为子项,除非增加容器大小,它也会失败。


    Container(
                  height: 22,
                  width: 22,
                  decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    color: Color(0xffF7825C),
                  ),
                  child: Center(
                    child: Icon(
                      Icons.add,
                      color: Colors.white,
                    ),
                  ),
                ) 

Run Code Online (Sandbox Code Playgroud)

小智 5

尝试这个:

             Container(
              alignment: Alignment.center,
              height: 22,
              width: 22,
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                color: Color(0xffF7825C),
              ),
              child: Icon(
                  Icons.add,
                  color: Colors.white,
                  size: 22 
                ),
            ) 
Run Code Online (Sandbox Code Playgroud)