nativ
nativ

Reputation: 39

Flutter border radius aspect

Someone knows how to do soft border radius, something like that :

enter image description here

Is it even possible with Flutter, I can't find how.

Upvotes: 0

Views: 746

Answers (2)

RealRK
RealRK

Reputation: 317

You can use ClipRect.

ClipRRect(
    // Change border radius and type(.zero, .roundrect, or absolute values) to get your desired effect
    borderRadius: BorderRadius.circular(8.0),
    child: Container(color: Colors.grey),
)

Upvotes: 0

Luis Cárcamo
Luis Cárcamo

Reputation: 348

You can achieve this by using the borderRadius property of the decoration inside a Container.

For example:

Column(
  mainAxisAlignment: MainAxisAlignment.spaceAround,
  children: [
     Container(
      height: 200,
      width: 200,
      decoration: BoxDecoration(
        color: Colors.blue,
        borderRadius: BorderRadius.all(Radius.elliptical(20, 10)),
      ),
    ),
    Container(
      height: 200,
      width: 200,
      decoration: BoxDecoration(
        color: Colors.blue,
        borderRadius: BorderRadius.all(Radius.circular(20)),
      ),
    ),
  ],
),

will yield this result

Example using decoration

on the other hand, if you want to have a different color for the border, you can try this, setting the color in the border property of the decoration property in the Container:

Center(
    child: Column(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: [
        Container(
          height: 200,
          width: 200,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.all(Radius.circular(20)),
            border: Border.all(
              color: Colors.red,
            ),
          ),
          child: Center(
            child: Text('Content...'),
          ),
        ),
      ],
    ),
),

the result for this is

Example using a border Color

Upvotes: 1

Related Questions