flutter 颜色,透明不透明度使背景颜色更暗-抖动

vjhs03f7  于 2023-05-19  发布在  Flutter
关注(0)|答案(3)|浏览(182)

我想为ElevatedButton设置一个渐变作为背景色。
所以我这样做了:

Container(
            height: 100,
            width: 100,
            decoration: const BoxDecoration(
                gradient: LinearGradient(
              begin: Alignment.topRight,
              end: Alignment.bottomLeft,
              colors: [
                Color(0xFFFE1871),
                Color(0xFFFD0E38),
                Color(0xFFFF0205),
              ],
            )),
            child: ElevatedButton(
                style: ElevatedButton.styleFrom(
                    backgroundColor: Colors.transparent),
                onPressed: () {},
                child: const Text(
                  'S\'inscrire',
                )),
          ),

但是渐变的颜色比预期的要深。
我想要的是

这是我的资料

Colors.transparent似乎有一些默认的不透明度。
怎么修?

qeeaahzv

qeeaahzv1#

添加阴影颜色

style: ElevatedButton.styleFrom(
  backgroundColor: Colors.transparent,
  shadowColor: Colors.transparent,
),
igetnqfo

igetnqfo2#

是shadowColor

ElevatedButton.styleFrom(
                    backgroundColor: Colors.transparent,
                   shadowColor: Colors.transparent,                                                     
                )

它的工作对我来说下面是代码和截图

Container(
        height: 100,
        width: 100,
        decoration: const BoxDecoration(
            gradient: LinearGradient(
          begin: Alignment.topRight,
          end: Alignment.bottomLeft,
          colors: [
            Color(0xFFFE1871),
            Color(0xFFFD0E38),
            Color(0xFFFF0205),
           
          ],
        )),
        child: ElevatedButton(
            style: ElevatedButton.styleFrom(
                backgroundColor: Colors.transparent,
               shadowColor: Colors.transparent,                                                     
            ),
            onPressed: () {},
            child: const Text(
              'S\'inscrire',
            )),
      )

fzsnzjdm

fzsnzjdm3#

我知道这可能不是最好的解决办法,但你可以试试这个

style: ElevatedButton.styleFrom(
backgroundColor: Colors.white.withOpacity(0),
shadowColor: Colors.white.withOpacity(0), ),

相关问题