Adding border to ClipRRect

6,385 views
Skip to first unread message

Mattias Månsson

unread,
May 19, 2019, 3:42:06 PM5/19/19
to Flutter Dev
Have posted a similar question, but I think it's better if I separate this issue as its own question. I wonder if it's possible to add a border to a cliprect (ClipRRect). If I add it as a decoration on the Container around it, I get a small white gap between the border and the clipped image. If I add the image in the decoration it looks fine, but as I said in the other issue I get layout problems instead then.

3rowwhite.png

You can clearly see the white border between the image and the real border above...

Widget _buildCompBar(BuildContext context) {
return Container(
padding: EdgeInsets.all(10),
height: 100,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: List<Widget>.filled(
widget._buildComp.length,
Expanded(
child: FittedBox(
fit: BoxFit.contain,
child: Container(
decoration: new BoxDecoration(
border: Border.all(width: 2),
borderRadius: new BorderRadius.all(Radius.circular(10.0)),
shape: BoxShape.rectangle,
),
child: new ClipRRect(
//clipBehavior: Clip.antiAlias,
borderRadius: new BorderRadius.circular(10.0),
child:
Image.asset("assets/images/mons/unit_icon_0000_0_0.png")),
),
)),
),
),
);
}


Mattias Månsson

unread,
May 19, 2019, 4:37:16 PM5/19/19
to Flutter Dev
I realize now I haven't set any color of the BoxDecoration, so I assume it has defaulted to white perhaps? Setting it to black does the trick...
Reply all
Reply to author
Forward
0 new messages