具有透明背景的图像显示白色背景

时间:2020-06-15 06:41:09

标签: flutter dart

所以我已经为此苦苦挣扎了一段时间,但是问题是,每当我在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

1 个答案:

答案 0 :(得分:0)

我无法复制该错误,

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

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

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

作为练习,您也可以尝试使用Flutter Card小部件来制作。这与图片非常相似,并且更具可定制性(尽管您需要消息图标)。