首页 > 解决方案 > 如何在 Flutter 中设置凸起按钮的背景颜色透明?

问题描述

这是我的代码,我想设置一个背景颜色,对我的按钮透明。

我想在我的代码中为两个 Raised Button 添加背景颜色。我也尝试用容器包装它,然后应用容器的背景透明,但它没有用。

         Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                FadeAnimation(
                  3.4,
                  SizedBox(
                    width: double.infinity,
                    height: 44,
                    child: RaisedButton(
                     color: Colors.white,
                      onPressed: navigateToSignUp,
                      child: Text(
                        'Sign Up',
                        style:
                            TextStyle(color: Colors.blueGrey, fontSize: 24),
                      ),
                    ),
                  ),
                ),

              SizedBox(height: 10),
                FadeAnimation(
                  3.4,
                  SizedBox(
                    width: double.infinity,
                    height: 44,
                    child: RaisedButton(
                      color: Colors.white,
                      onPressed: navigateToSignIn,
                      child: Text(
                        'Sign In',
                        style: TextStyle(color: Colors.grey, fontSize: 24),
                      ),
                    ),
                  ),
                ),

标签: flutter

解决方案


您可以Opacity使用black颜色

像这样 :

 color: Colors.black.withOpacity(0.05), //set this opacity as per your requirement

它会看起来更有吸引力


推荐阅读