How to add gradient color in card?

2,019

Try below code hope it help to you in below answer change Color your need.

         Card(
            child: Container(
              height: 50,
              width: 150,
              decoration: BoxDecoration(
                gradient: LinearGradient(
                  colors: [
                    Colors.yellow,
                    Colors.orangeAccent,
                    Colors.yellow.shade300,
                  ],
                  begin: Alignment.topLeft,
                  end: Alignment.bottomRight,
                ),
              ),
              child: Container(), //declare your widget here
            ),
          ),

Your Card look like-> enter image description here

If you are gradient background to card or gradient border to card try below code

  Container(
        
          height: 50,
          width: 150,
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [
                Colors.yellow,
                Colors.orangeAccent,
                Colors.yellow.shade300,
              ],
              begin: Alignment.topLeft,
              end: Alignment.bottomRight,
            ),
          ),
        child:Card(
          color:Colors.white,
          child: Container(), //declare your widget here
        ),
      ),

Your Screen like -> enter image description here

Share:
2,019
Chloé
Author by

Chloé

Updated on December 01, 2022

Comments

  • Chloé
    Chloé over 1 year

    How to add gradient color in the background of a card ? Should I reproduce this card with a container and a box decoration or is there another simple way ?

  • Filipe Piletti Plucenio
    Filipe Piletti Plucenio over 2 years
    Let me know if this helped you.
  • Chloé
    Chloé over 2 years
    Thx but it does not fit the border of the card :(
  • Chloé
    Chloé over 2 years
    Thx but it does not fit the border of the card :(
  • Chloé
    Chloé over 2 years
    Thx, this is the best alternative I had, but you must also add circle border and an InkWell widget to do it like a card. I will do this if there is no other solution..
  • Ravindra S. Patil
    Ravindra S. Patil over 2 years
    Refer my updated answer, one thing forgot black color of updated image try updated code hope it's helpful to you
  • Chloé
    Chloé over 2 years
    Thank you but it still does not fit the border radius of the card.
  • Ravindra S. Patil
    Ravindra S. Patil over 2 years
    can you tell me the what do you want in image or picture?
  • Chloé
    Chloé over 2 years
    I do not need an image or a picture, but a gradient color.
  • Ravindra S. Patil
    Ravindra S. Patil over 2 years
    Are you Try my answer?