简体   繁体   English

如何在 Flutter 中使用背景颜色正确居中图标?

[英]How do I center the icon properly with background color in Flutter?

How do I make sure the icon is centered?如何确保图标居中? I do not get why this is happening.我不明白为什么会这样。

Tried things like:尝试过类似的事情:

alignment: Alignment.center

And:和:

  padding: EdgeInsets.zero,

And:和:

shrinkWrap: true,

Here is the full code:这是完整的代码:

                child:     Column(
                  children: [
                    Container(
                      margin: new EdgeInsets.only(left: 25, right: 15),
                      padding: const EdgeInsets.all(10.0),
                      decoration: BoxDecoration(
                        color: Colors.red,
                        borderRadius: BorderRadius.circular(20.0),
                      ),
                      child: Icon(
                        MyIcons.icons,
                        size: 24,
                      ),
                    ),

                    Text("Menu item 1")
                  ],
                ),

菜单项

Nothing seems to work.似乎没有任何效果。 Can you help?你能帮我吗?

The problem seems to be coming from custom Icon, change it to问题似乎来自自定义图标,将其更改为

     Icon(
          Icons.home,
          size: 24,
        ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM