为什么我的图像在抖动中失去了渐变?
Why does my image lose its gradient in flutter?
当我遇到这个问题时,我正在尝试创建一个欢迎页面。起初,一切都很好,但是当我使用 DecorationImage 插入图像时,看起来我的图像在颜色渐变方面有错误。真实图像是这样的:
但是当我 运行 我的应用程序时,我得到这个:
我在 Scaffold 中使用 PageView.Builder 来显示我的图片。我的代码如下所示:
return Scaffold(
body: PageView.builder(
scrollDirection: Axis.vertical,
itemCount: img.length,
itemBuilder: (_,index){
return Container(
width: double.maxFinite,
height: double.maxFinite,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/image/"+img[index]
),
fit: BoxFit.cover
)
),
我将我所有的图片名称放在一个列表中,并使用索引来调用每个图片。
金鱼看起来差不多,但底部的渐变被扰乱了。起初,我以为是因为我使用的是低规格的虚拟设备,但后来我尝试使用不同的虚拟设备,仍然得到相同的结果。为什么会这样?有谁知道我错在哪里?
编辑:我尝试添加 FilterQuality
return Container(
width: double.maxFinite,
height: double.maxFinite,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/image/"+img[index]
),
fit: BoxFit.cover,
filterQuality:FilterQuality.high
)
),
但是没有任何反应。是我写错了吗?
我试过使用真实设备并且它有效,但我不知道为什么
当我遇到这个问题时,我正在尝试创建一个欢迎页面。起初,一切都很好,但是当我使用 DecorationImage 插入图像时,看起来我的图像在颜色渐变方面有错误。真实图像是这样的:
但是当我 运行 我的应用程序时,我得到这个:
我在 Scaffold 中使用 PageView.Builder 来显示我的图片。我的代码如下所示:
return Scaffold(
body: PageView.builder(
scrollDirection: Axis.vertical,
itemCount: img.length,
itemBuilder: (_,index){
return Container(
width: double.maxFinite,
height: double.maxFinite,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/image/"+img[index]
),
fit: BoxFit.cover
)
),
我将我所有的图片名称放在一个列表中,并使用索引来调用每个图片。
金鱼看起来差不多,但底部的渐变被扰乱了。起初,我以为是因为我使用的是低规格的虚拟设备,但后来我尝试使用不同的虚拟设备,仍然得到相同的结果。为什么会这样?有谁知道我错在哪里?
编辑:我尝试添加 FilterQuality
return Container(
width: double.maxFinite,
height: double.maxFinite,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/image/"+img[index]
),
fit: BoxFit.cover,
filterQuality:FilterQuality.high
)
),
但是没有任何反应。是我写错了吗?
我试过使用真实设备并且它有效,但我不知道为什么