首页 > 解决方案 > 在颤动中使用颜色渐变的容器顶部添加图像和后退箭头不起作用

问题描述

我正在尝试在具有背景渐变颜色的容器顶部添加图像和白色后退箭头,同时当然保留背景。这是我想要的结果:

在此处输入图像描述

这是我尝试过的代码:

    Stack(
      children: <Widget>[
        Container(
          height: 200,
          decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topLeft,
              end: Alignment.bottomRight,
              colors: <Color>[Color(0xffb21fc3), Color(0xff960cd1)],
            ),
          ),
        ),
        Image.asset(
          'assets/vip_big.jpg',
          colorBlendMode: BlendMode.overlay,
        ),
        Positioned(
          top: 45,
          left: 15,
          child: IconButton(
              icon: Icon(
                Icons.arrow_back_ios,
                size: 45.0,
                color: Colors.white,
              ),
              onPressed: () {}),
        ),
      ],
    ),

这是我得到的:

在此处输入图像描述

我需要进行哪些更改才能获得正确的输出?

标签: imageflutterbackgroundcontainers

解决方案


将白色从图像替换为透明。现在,因为图像是 jpeg,所以没有透明度。因此图像与您的渐变容器重叠。


推荐阅读