Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounded corner Card Widget with right border in flutter

Tags:

flutter

dart

I have to create a Card like this:

enter image description here

I had written below code to achieve the desired UI, but it didn't work as expected.

Card(   elevation: 5,   shape: RoundedRectangleBorder(     borderRadius: BorderRadius.only(       bottomRight: Radius.circular(10),       topRight: Radius.circular(10)),     side: BorderSide(width: 5, color: Colors.green)),   child: ListTile(), ) 

The code above produced this:

enter image description here

Whereas using the code below:

Card(   elevation: 5,   shape: Border(right: BorderSide(color: Colors.red, width: 5)),   child: ListTile(), ) 

generated this output:

enter image description here

How can I create the required UI in flutter?

like image 376
David Bronn Avatar asked Mar 23 '19 17:03

David Bronn


People also ask

How do you make the card border rounded in flutter?

You can set the shape property to RoundedRectangleBorder() or CircleBorder() in order to create a circle Card. If you use RoundedRectangleBorder, the key point here is to increase the border radius to a large number, at least half the width of the Card's child.

How do I make rounded corners in ListTile in flutter?

In Flutter, you can implement a ListTile widget with rounded corners by setting its shape property to RoundedRectangleBorder(/*… */).


2 Answers

Use the shape parameter in the Card widget, example:

Card(       shape: RoundedRectangleBorder(         borderRadius: BorderRadius.circular(15.0),       ),       child: Container() ) 
like image 54
Julian Shaw Avatar answered Oct 16 '22 01:10

Julian Shaw


I have used ClipPath to achieve the UI asked in the question, check out the below code.

Card(      elevation: 2,      child: ClipPath(        child: Container(               height: 100,               decoration: BoxDecoration(               border: Border(right: BorderSide(color: Colors.green, width: 5))),             ),        clipper: ShapeBorderClipper(shape: RoundedRectangleBorder(                     borderRadius: BorderRadius.circular(3))),                ),     ) 

This gives the below output, enter image description here

If there is a better way to achieve said result kindly do answer.

like image 24
David Bronn Avatar answered Oct 16 '22 01:10

David Bronn