Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create outlined Card widget in Flutter

I want to include a outlined material card with flutter, but since the card widget doesn't have a style element or something similar, I am not sure how to implement this.

I tried using the shape: property but wasn't very successful, mostly because I didn't understand how it works.

enter image description here

like image 532
jonasxd360 Avatar asked Aug 22 '19 15:08

jonasxd360


People also ask

How do you add an outline border in Flutter?

Steps to add border to container in Flutter:Step 1: Go to the Container in which you want to add a border. Step 2: Add the decoration parameter and assign the BoxDecoration class. Inside the BoxDecoration add the parameter border and set it to Border. all().

What is the use of key in Flutter?

Key class Null safety A Key is an identifier for Widgets, Elements and SemanticsNodes. A new widget will only be used to update an existing element if its key is the same as the key of the current widget associated with the element. Your browser can't play this video.


1 Answers

Output:

enter image description here

It has shape property which takes a Border you can change that.

Card(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(40), // if you need this
    side: BorderSide(
      color: Colors.grey.withOpacity(0.2),
      width: 1,
    ),
  ),
  child: Container(
    color: Colors.white,
    width: 200,
    height: 200,
  ),
)

I think the screenshot you showed can also be achieved by just using elevation property of the Card.

like image 76
CopsOnRoad Avatar answered Nov 15 '22 06:11

CopsOnRoad