如何在 Flutter 中调整图标/图标按钮的大小? [英] How to resizing an Icon / Icon Button in Flutter?

查看:94
本文介绍了如何在 Flutter 中调整图标/图标按钮的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 个问题.

  1. 如何缩放我们的图标?我的意思不是 Flutter 的默认图标.但是当您更改为图像时.我有一个带有如下图像的图标按钮:

Row(
                        mainAxisSize: MainAxisSize.max,
                        children: <Widget>[
                          IconButton(
                            icon: new Image.asset("images/IG.png"),
                          ),
                          IconButton(
                            icon: new Image.asset("images/Twitter.png"),
                          ),
                          IconButton(
                            icon: new Image.asset("images/Fb.png"),
                          ),
                        ],
                      )

它只有 3 个图标.当我添加更多图标时,它会将布局分解为黄黑色的砖块.如何让它们变小?

its only 3 icons. when I add more icon, its gonna break the layout into bricks yellow-black. how to make them become smaller ?

  1. 上面的问题是针对 IconButton 的.如何用图像更改图标?这是代码:

  1. Question above is for IconButton. how to change an Icon with an Image ? here are the code:

图标(Icons.star, color: Colors.red)

如何使用 Image.asset 更改star"?没有任何对其他链接的引用,仅显示图标.

how to change the 'star' with Image.asset ? without any referal to other link, that only show the icon.

推荐答案

Icon 可以使用 size 属性.

Icon(
  Icons.radio_button_checked,
  size: 12,
),

对于 IconButton 你可以使用

Transform.scale(
  scale: 0.5,
  child: IconButton(
    onPressed: (){},
    icon: new Image.asset("images/IG.png"),
  ),
),

这篇关于如何在 Flutter 中调整图标/图标按钮的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆