I have to create a Card like this:
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:
Whereas using the code below:
Card( elevation: 5, shape: Border(right: BorderSide(color: Colors.red, width: 5)), child: ListTile(), )
generated this output:
How can I create the required UI 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.
In Flutter, you can implement a ListTile widget with rounded corners by setting its shape property to RoundedRectangleBorder(/*… */).
Use the shape parameter in the Card widget, example:
Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), child: Container() )
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,
If there is a better way to achieve said result kindly do answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With