Search code examples
colorsflutter

Flutter Card with Transparent Background


I am trying to make my card transparent in order to show the thing in background.

I had tries to set color property of card to transparent, but it is show gray kind of background with opacity.

Result

I also tries use white color with different opacity, but the result outcome is not pure white color with transparent.

   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"),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );

other white color but still not white at all

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

How can I achieve to have a pure white background with transperant?


Solution

  • try setting the elevation to 0, it should work

    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"),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        );