颤振复杂线性梯度不起作用

时间:2021-04-13 14:25:07

标签: flutter user-interface flutter-layout

enter image description here

以上是预期的输出。

我需要在 Flutter 中实现这个渐变,但它并没有例外。

颜色:#6646E7

颜色偏移非常严格且不平滑,如图所示。 下面是我想使用的容器

完整代码:

Stack(
      alignment: Alignment.bottomRight,
      children: [
        Container(
          margin: const EdgeInsets.only(left: 10, right: 10, top: 15),
          padding: const EdgeInsets.all(20),
          decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(15),
              color: Colors.white,
              border: Border.all(color: Colors.white, width: 2),
              // gradient: LinearGradient(
              //     begin: Alignment.topLeft,
              //     end: Alignment.bottomRight,
              //     stops: const [
              //       0.01,
              //       0.1,
              //       0.9
              //     ],
              //     colors: [
              //       const Color(0xff6646E7).withOpacity(0.4),
              //       Colors.white,
              //       const Color(0xff6646E7).withOpacity(0.4),
              //     ]),
              // boxShadow: [
              //   const BoxShadow(
              //       color: Color.fromRGBO(0, 0, 0, 0.25),
              //       blurRadius: 3,
              //       spreadRadius: 1,
              //       offset: Offset(0, 4))
              // ]),
              ),
          child: Column(
            children: [
              Row(
                children: [
                  SvgPicture.asset('assets/profile/$icon.svg'),
                  const SizedBox(
                    width: 10,
                  ),
                  Text(
                    title,
                    style: TextStyle(
                        fontSize: 20,
                        fontWeight: FontWeight.w600,
                        fontFamily: GoogleFonts.poppins().fontFamily),
                  )
                ],
              ),
              const SizedBox(
                height: 20,
              ),
              child
            ],
          ),
        ),
        Positioned(
          right: 10,
          child: GestureDetector(
              onTap: onEditPressed,
              child: SvgPicture.asset('assets/profile/edit_pen.svg')),
        )
      ],
    );

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

试试这个,

decoration: BoxDecoration(
  gradient: LinearGradient(
    colors: [
      Colors.black38,
      Colors.black12,
      Colors.black12,
      Colors.black38,
    ],
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
  ),
),

Colors.black38Colors.black12 更改为您想要的颜色。