【问题标题】:How to center an Icon in an ElevatedButton?如何使图标在 ElevatedButton 中居中?
【发布时间】:2021-12-16 21:57:38
【问题描述】:

如何使我的图标在 ElevatedButton 小部件中居中?

这是我的代码:

ElevatedButton(
  style: ElevatedButton.styleFrom(
    shape: CircleBorder(),
    primary: itemColor.color),
  child: Center(child: Icon(Icons.check, color: Colors.white))
);

【问题讨论】:

    标签: flutter button alignment


    【解决方案1】:

    试试下面的代码希望对你有帮助。

         ElevatedButton(
                onPressed: () {},
                style: ElevatedButton.styleFrom(
                  shape: CircleBorder(),
                ),
                child: Icon(
                  Icons.check,
                  color: Colors.white,
                ),
              ),
    

    您的结果屏幕->

    【讨论】:

    • 它也不起作用。我在左边有一个填充。
    • 你可以添加你的输出截图
    猜你喜欢
    • 2021-06-03
    • 1970-01-01
    • 2018-02-27
    • 2013-12-07
    • 1970-01-01
    • 2022-06-26
    • 1970-01-01
    • 2021-08-22
    • 2019-09-09
    相关资源
    最近更新 更多