Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter :- Create circular border around icons

I want to create circular borders around the icons as shown in the image. layout

Container(
              margin: EdgeInsets.all(20),
              padding: EdgeInsets.all(10),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(100),
                color: Colors.white,
                border: Border.all(
                  width: 2
                )
              ),
              child: Icon(Icons.arrow_downward,color: Colors.white,),
            )

I don't need cuts in the circular borders as they are shown in the image but the complete circular border, I have also tried this code =>This Answer

like image 211
Atul Chaudhary Avatar asked Nov 07 '19 09:11

Atul Chaudhary


People also ask

How do you make a custom border on flutter?

To add border to image in Flutter, first, wrap the Image widget inside the Container widget. Inside the Container, add the decoration property and assign the BoxDecoration widget. Using the border property of BoxDecoration, you can provide the Border. all() widget to create border around the image.

How can I add a border to a widget in flutter?

Steps to add border to container in Flutter:Step 1: Go to the Container in which you want to add a border. Step 2: Add the decoration parameter and assign the BoxDecoration class. Inside the BoxDecoration add the parameter border and set it to Border. all().

How do I change the icon border color in flutter?

Steps to change icon button color in FlutterLocate the file where you have placed the IconButton widget. Inside the IconButton widget, add the color parameter and assign the color of your choice. Run the App.


2 Answers

Container(
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              border: Border.all(color: Colors.white)
            ),
            child: Icon(Icons.check, color: Colors.white,),
          )

or you can use Material if you're going to need some fancy effects:

Material(
            color: Colors.transparent,
            shape: CircleBorder(
              side: BorderSide(color: Colors.white)
            ),
            child: Icon(Icons.check, color: Colors.white,),
          )
like image 149
Filip P. Avatar answered Sep 18 '22 12:09

Filip P.


I am doing some mistakes in my above code. but I have figured out and here is the new code.

Container(
                  margin: EdgeInsets.all(20),
                  padding: EdgeInsets.all(10),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(100),
                      border: Border.all(width: 2, color: Colors.white)),
                  child: Icon(
                    Icons.cancel,
                    color: Colors.white,
                  ),
                )),

Also if you want to make complete Widget clickable then you can use it like this.

GestureDetector(
            onTap: () {
              //Navigator.of(context).pop();

            },
            child: new Align(
                alignment: Alignment.bottomRight,
                child: Container(
                  margin: EdgeInsets.all(20),
                  padding: EdgeInsets.all(10),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(100),
                      border: Border.all(width: 2, color: Colors.white)),
                  child: Icon(
                    Icons.cancel,
                    color: Colors.white,
                  ),
                )),
          ),
like image 22
Atul Chaudhary Avatar answered Sep 18 '22 12:09

Atul Chaudhary