Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border radius of container inside card

When I try to set the border radius of the top two corners of my container that is nested inside a card, the whole content of the container goes disappears. Here is my code, if you uncomment the commented line your whole content inside the container will go away.

Widget build(BuildContext context) {
    return Card(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(5.0),
      ),
      margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
      child: Container(
        decoration: BoxDecoration(
          border: new Border(
              top: BorderSide(
            color: Theme.of(context).primaryColor,
            width: 3.0,
          )),
          //borderRadius: BorderRadius.only(topLeft: const Radius.circular(5.0)),
        ),
        child: makeListTile(widget.flight),
      ),
    );

}

like image 981
user2876983 Avatar asked Jul 07 '19 00:07

user2876983


People also ask

How do you set the border radius of a container?

To set border radius for Container widget, set its decoration property with BoxDecoration where the borderRadius property is set with required value.

How do you make rounded corners in ListTile?

To add a border radius or create a rounded border around the ListTile, you can define the shape parameter with the RoundedRectangleBorder widget. Inside the RoundedRectangleBorder you can add side parameter with BorderSide(width: 2) and borderRadius with BorderRadius. circular(50).


1 Answers

Just add

clipBehavior: Clip.antiAlias

To Card

like image 199
Ali mohammadi Avatar answered Oct 08 '22 19:10

Ali mohammadi