How to create circle container with border in flutter?

8,223

Solution 1

    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
          ),
        ),
      ),

Ref:

Solution 2

Container(
            height: 200,
            width: 200,
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              border: Border.all(width: 1, color: Colors.red)
            ),
          ),
Share:
8,223
MD MEHEDI HASAN
Author by

MD MEHEDI HASAN

Hi! I AM FLUTTER DEVELOPER šŸ‘‹ šŸ”­ Iā€™m currently working on augnitive.com šŸŒ± Iā€™m currently learning Dart & Flutter || Python & Django šŸ‘Æ Iā€™m looking to collaborate on Flutter & Django Development šŸ¤” Iā€™m looking for help with Flutter & Django Development šŸ’¬ Ask me about: Dart, Flutter, UX-UI, Python, Django šŸ“« How to reach me: [email protected] or Direct Contact: +8801790180825 āš” Fun fact: coffee and bugs

Updated on December 28, 2022

Comments

  • MD MEHEDI HASAN
    MD MEHEDI HASAN over 1 year

    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

  • Ismaeel Sherif
    Ismaeel Sherif over 2 years
    this works better than using the border parameter because it doesn't leave white pixels around the circular border