3

I would like to know how to make a smooth rounded corner in Flutter. I found a similar link to iOS approach - smooth rounded corners in swift but it did not help me find a solution to Flutter approach. I thought ContinuousRectangleBorder is the way, but it is not the shape I am looking for. I think some kind of clipper should work.

Stepan
  • 1,041
  • 5
  • 23
  • 35
  • `Smooth rounded corner` ? You mean `rounded corner` ? – dm_tr Jan 03 '21 at 19:57
  • No, smooth rounded corner radius, there is link to similar issue. Here is the explanation https://medium.com/@arthurofbabylon/a-smooth-corner-radius-in-ios-54b80aa2d372 – Stepan Jan 03 '21 at 20:05

3 Answers3

10

I published a dedicated package that might help you : figma_squircle.

Container(
    height: 100,
    width: 100,
    decoration: ShapeDecoration(
        color: Colors.red.withOpacity(0.75),
        shape: SmoothRectangleBorder(
            borderRadius: SmoothBorderRadius(
              cornerRadius: 10,
              cornerSmoothing: 0.5,
            ),
        ),
    ),
)
Alois
  • 170
  • 3
  • 9
-2

You can try the following code

ClipRRect(
borderRadius:
      BorderRadius.circular(15.0),
child: // Your widget that needs to be rounded.
)

For more information, you can check this reference video

Abdullah Khan
  • 1,046
  • 8
  • 14
-2

There is no natural way to do this with Flutter. If you really want to accomplish this, use the technique used in your article where you overlay the square with a circle with a Stack widget. This looks like the following:

Stack(children: [
          Container(
              height: 100,
              width: 100,
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                color: Colors.amber,
              )),
          Container(
            height: 100,
            width: 100,
            decoration: BoxDecoration(
              color: Colors.amber,
              borderRadius: BorderRadius.all(Radius.circular(16)),
            ),
          ),
        ]),

This will create a square that looks like:

enter image description here

You might need to mess around with the height and width of the square and the circle but you get the idea.

Gabe
  • 5,643
  • 3
  • 26
  • 54