How to use Flutter Card Widget
Let’s find the answer to the question of what is Flutter card widget and how to use it to make your Flutter app more professional and visually appealing for its users.
We’ll understand the parameters of the card widget Flutter with proper code examples and easy explanations so it’s easy for you to implement in your own Flutter code.
What is the Flutter Card Widget?
This is actually a box that looks like it’s raised from the other items. It can hold Flutter widgets like text, buttons, etc.
We can change the appearance of card Flutter widget by giving it a custom shadow, giving it a color, or playing with its other parameters which we will discuss practically.
The use of Flutter card widget is when you want to show something on a small portion of the screen to make it look beautiful like image with details(name, age, etc), a product with details, and many more.
Let’s now understand this Flutter widget with easy Flutter code examples.
Syntax
Card()
Parameter of Card Flutter Widget
- child
- color
- elevation
- margin
- shape
- borderOnForeground
Examples to understand Flutter Card Widget Practically
Example 1: ‘child’ parameter
Card( child: Text('I am inside Flutter Card'), )

Example 2: ‘color’ parameter
color: Colors.blue

Example 3: ‘elevation’ Parameter to Give shadow to Card
elevation: 10

Example 4: ‘margin’ parameter of Card Widget Flutter
margin: EdgeInsets.all(21)

Example 5: ‘shape’ parameter
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(21))

Example 5.1: only() method
BorderRadius.only( topLeft: Radius.circular(21), bottomRight: Radius.circular(29))

Example 5.2: horizontal() method
BorderRadius.horizontal(left: Radius.circular(51))

Example 5.3: Beleved shape to Card widget borders
shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(15))

Example 5.4: Continuous shape of card borders
shape: ContinuousRectangleBorder(borderRadius: BorderRadius.circular(41))

Example 6: borderOnForeground Parameter
This parameter in the Card widget specifies whether the card’s border is drawn in front of or behind the card’s child content. It takes a boolean value and it is true by default.
Example 6.1: borderOnForeground is true
Card( borderOnForeground: true, // Border shown in front of content shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), side: BorderSide(color: Colors.red, width: 4), ), child: Container( height: 150, width: 150, color: Colors.green, child: Center(child: Text('Border Front')), ), )

Example 6.2: borderOnForeground is false
borderOnForeground: false

Conclusion
I hope the customization of different parameters of Flutter card widget was easy for you. I’ve tried very easy examples with explanations to make things super easy to learn.
If you still find any issues, then comment down or email me. I’d be happy to help you.
Thank you and must visit my other articles on other important Flutter widgets as well.