Reputation: 4987
I need to make Container edge circle and how to do that when i try RoundedRectangleBorder it showing error
Container(
width: 100,height: 100,
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.orange,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(18.0),
)
),
),
Upvotes: 8
Views: 6059
Reputation: 289
The container is no longer accepting RoundedRectangledBorder as a shape, You've to use the BoxShape class only for the shape property
But still, you can achieve the desired behavior like this
Container(decoration: BoxDecoration(border: Border.all(color: Colors.purple, width:2),color:Colors.purple.withOpacity(0.2),shape:BoxShape.rectangle,borderRadius: BorderRadius.circular(12.0)),
By doing this you can give borderRadius,shape and borders as well
if you're not getting the borderRadius the you can wrap your container inside a ClipRRect() and access the borderRadius property inside the ClipRRect
Upvotes: 0
Reputation: 8010
This error suggests,
argument type
RoundedRectangleBorder
cannot be assigned to parameter typeBoxShape
So if you want to use RoundedRectangleBorder
then you have to use it inside shape
parameter,
Container(
width: 100,height: 100,
margin: EdgeInsets.all(10.0),
decoration: ShapeDecoration(
color: Colors.orange,
shape: RoundedRectangleBorder( // <--- use this
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
),
),
Output,
@Anil Chauhan's approach is also correct so you can use that too.
Upvotes: 7
Reputation: 716
Try this:
Container(
width: 100,height: 100,
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(10.0)
),
),
Upvotes: 2