简体   繁体   English

颤振移动网络无法更改资产图像颜色

[英]flutter mobile web can't change assets image color

I'm developing a flutter web, and I checked on the mobile web that the color of the icon image is strange.我正在开发一个颤振网络,我在移动网络上检查了图标图像的颜色很奇怪。

    IconButton(
      onPressed: () {},
      icon: ImageIcon(
        AssetImage('assets/images/heart_selected.png'),
        color: Colors.redAccent,
      ),
    ),

I'm printing the heart icon as below, and the color of the icon should be 'redAccent' as set in the code.我正在打印如下心形图标,并且图标的颜色应为代码中设置的“redAccent”。
And when I checked on the web, it was printed well.当我在网上查看时,它打印得很好。 However, when viewed on the mobile web, it is output only in black, not in the set color.但是,在移动网络上查看时,它仅输出黑色,而不是设置的颜色。 (the same goes for other colors.) Perhaps the color of the icon image has not been changed at all. (其他颜色也一样。)也许图标图像的颜色根本没有改变。

There is no problem with the flutter icon widget. flutter icon 小部件没有问题。 May I know the cause of this?我可以知道这是什么原因吗?

Thank you.谢谢你。

Try to use Image.asset instead of image icon.尝试使用 Image.asset 而不是图像图标。 Image.图片。 Asset also has a color key available to customise资产还有一个颜色键可用于自定义

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

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