Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create circle container with border in flutter?

As you can notice, the background color of the decoration is slightly overflowing the circular border. I've tried in different ways (e.g. using ClipOval) but the result is always the same.

enter image description here

like image 524
MD MEHEDI HASAN Avatar asked Mar 03 '26 06:03

MD MEHEDI HASAN


2 Answers

I have just faced the same issue. Easy workaround:

     Container(
        width: 28,
        height: 28,
        decoration: BoxDecoration(
          color: Colors.green.withOpacity(0.25), // border color
          shape: BoxShape.circle,
        ),
        child: Padding(
          padding: EdgeInsets.all(2), // border width
          child: Container( // or ClipRRect if you need to clip the content
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              color: Colors.blue, // inner circle color
            ),
            child: Container(), // inner content
          ),
        ),
      ),

Reference

like image 118
MD MEHEDI HASAN Avatar answered Mar 05 '26 05:03

MD MEHEDI HASAN


Container(
            height: 200,
            width: 200,
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              border: Border.all(width: 1, color: Colors.red)
            ),
          ),
like image 32
Falgun Sonwane Avatar answered Mar 05 '26 07:03

Falgun Sonwane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!