【问题标题】:Flutter Card with Transparent Background透明背景的颤振卡
【发布时间】:2019-04-12 16:03:23
【问题描述】:

我正在尝试让我的卡片透明以便在背景中显示该东西。

我曾尝试将卡片的颜色属性设置为透明,但它显示的是灰色的不透明背景。

我也尝试使用具有不同不透明度的白色,但结果不是透明的纯白色。

   Card(
      color: Colors.transparent,
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            CardLabelSmall("Current Premix Plan Document"),
            Expanded(child: PremixPlanDocList()),
            Row(
              children: <Widget>[
                Expanded(
                  child: RaisedButton(
                    onPressed: () async {
                      homeBloc.retrieveCurrentMrfPremixPlan();
                    },
                    child: const Text("Retrieve Premix Plan"),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );

其他白色,但仍然不是白色

color: Colors.white70,
color: Colors.white54,
color: Colors.white30,

如何实现纯白背景和透明?

【问题讨论】:

    标签: colors flutter


    【解决方案1】:

    尝试将elevation 设置为 0,它应该可以工作

    Card(
          elevation: 0,
          color: Colors.transparent,
          child: Padding(
            padding: const EdgeInsets.all(16),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: <Widget>[
                CardLabelSmall("Current Premix Plan Document"),
                Expanded(child: PremixPlanDocList()),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: RaisedButton(
                        onPressed: () async {
                          homeBloc.retrieveCurrentMrfPremixPlan();
                        },
                        child: const Text("Retrieve Premix Plan"),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        );
    

    【讨论】:

      【解决方案2】:

      你可以试试这样的。

        new Container(
                      height: 300.0,
                      color: Colors.blue,
                      child: new Card(
                          color: Colors.transparent,
                          child: new Center(
                            child: new Text("Hi modal sheet"),
                          )),
                    ),
      

      【讨论】:

        猜你喜欢
        • 2019-05-29
        • 2022-01-24
        • 2020-01-22
        • 1970-01-01
        • 2020-10-01
        • 2019-01-24
        • 2014-01-28
        • 2022-01-23
        • 2018-10-05
        相关资源
        最近更新 更多