I'm making a Container()
, I gave it a border, but it would be nice to have rounded borders.
This is what I have now:
Container(
width: screenWidth / 7,
decoration: BoxDecoration(
border: Border.all(
color: Colors.red[500],
),
),
child: Padding(
padding: EdgeInsets.all(5.0),
child: Column(
children: <Widget>[
Text(
'6',
style: TextStyle(
color: Colors.red[500],
fontSize: 25),
),
Text(
'sep',
style: TextStyle(
color: Colors.red[500]),
)
],
),
),
);
I tried putting ClipRRect
on it, but that crops the border away. Is there a solution for this?
In flutter, it is simple to create an easy rectangle and sq. form using container widget however they need sharp edges and therefore the corner is sharp however using the BoxDecoration property of box decoration we are able to simply and make the perimeters rounded. Container( decoration: BoxDecoration( border: Border.
In flutter, it is simple to create an easy rectangle and sq. form using container widget however they need sharp edges and therefore the corner is sharp however using the BoxDecoration property of box decoration we are able to simply and make the perimeters rounded.
Want to show a widget with rounded borders in Flutter? Just wrap your widget with a DecoratedBox and give it a decoration like this: DecoratedBox( decoration: BoxDecoration( color: Colors.blue, borderRadius: const BorderRadius.all(Radius.circular(16)), // alternatively, do this: // borderRadius: BorderRadius.circular (16), ) child: someWidget, )
Edit: The rounded shadow you are getting is because of the offset that you have used for the inner container. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.
FlutterAgency.com is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.
Try using the property borderRadius
from BoxDecoration
Something like
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.red[500],
),
borderRadius: BorderRadius.all(Radius.circular(20))
),
child: ...
)
To make it completely circle:
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
),
)
To make it a circle at selected spots:
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(40.0),
bottomRight: Radius.circular(40.0),
topLeft: Radius.circular(40.0),
bottomLeft: Radius.circular(40.0)),
),
child: Text("hello"),
),
or
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
),
child: ...
)
You can use like this. If you want border for all the corners you can use like bellow.
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(12.0),
),
),
),
If you want rounded borders for selected sides only you can use like below.
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
),
),
child: Text('Text'),
),
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