【问题标题】:Images with transparent backgrounds show white background具有透明背景的图像显示白色背景
【发布时间】:2020-06-15 06:41:09
【问题描述】:

所以我一直在为此苦苦挣扎,但问题是每当我在我的 ui 中添加图像时,它都会显示白色背景,即使它应该是透明的,我也检查了我的 pubspec.yaml 文件并且图像很好导入,但我只是不知道为什么它将透明背景显示为白色

GestureDetector(
                    onTap: () {},
                    child: Container(
                      child: Image.asset("assets/send.png"),
                      padding: EdgeInsets.all(10),
                      height: 40,
                      width: 40,
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(40),
                          gradient: LinearGradient(
                              colors: [Colors.blue, Colors.lightBlue])),
                    ),
                  )

这是我正在编写的代码,图像显示如下: The image that has a transparent background has a white background now for some reason

任何帮助将不胜感激,非常感谢您的阅读。

The image in question without the Gesture detector and bigger so the transparent parts are more visible

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    我无法复制那个错误,

    但在我的设备上,它只显示带有装饰的图像。

    也许首先尝试在 Flutter 中使用它,而不用装饰或 GestureDetector。如果可行,请再试一次。

    另外,我看不出您的图像应该在哪里透明。如果该链接正确,我只会看到没有任何透明部分的 359x58 图像。

    作为练习,您也可以尝试使用 Flutter Card 小部件来制作它。这与图像非常相似,而且更可自定义(不过您需要消息图标)。

    【讨论】:

    • 谢谢你的回复,我试过你说的,虽然它仍然显示它应该是透明的部分,我夸大了尺寸以使透明背景更明显,并将用我的图像更新帖子想用
    猜你喜欢
    • 2018-10-31
    • 2012-07-26
    • 2023-04-10
    • 2013-09-26
    • 2013-11-27
    • 1970-01-01
    • 2021-04-28
    • 2014-08-21
    • 1970-01-01
    相关资源
    最近更新 更多