Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make border on FloatingActionButton?

my problem is i want to do border around my floatingactionbutton. I tried to put it into container and do like this, but it's not what i want.

        decoration: BoxDecoration(
            border: Border.all(
                color: Colors.brown, width: 5, style: BorderStyle.solid)),
        margin: const EdgeInsets.fromLTRB(0, 0, 0, 55),
        width: 80,
        height: 80,
        child: FloatingActionButton(
          focusColor: Colors.white54,
          backgroundColor: Colors.white,
          onPressed: () {},
          child: const Icon(
            Icons.add,
            color: Colors.black,
            size: 50,
          ),
        ),
      ),

I have this:

enter image description here

I want this:

enter image description here

like image 472
Malak Avatar asked Oct 12 '25 03:10

Malak


2 Answers

In FloatingActionButton widget you have property named shape using that you can achieve your desired result.

   FloatingActionButton(
          backgroundColor: Colors.white,
          onPressed: (){},
          child: Icon(Icons.add,color: Colors.black,size: 30,),
          shape: RoundedRectangleBorder(side: BorderSide(width: 3,color: Colors.brown),borderRadius: BorderRadius.circular(100)),
        )
like image 175
Diwyansh Avatar answered Oct 14 '25 18:10

Diwyansh


just use shape: BoxShape.circle,

Container(
      decoration: BoxDecoration(
        shape: BoxShape.circle,
          border: Border.all(
              color: Colors.brown, width: 5, style: BorderStyle.solid)),
      margin: const EdgeInsets.fromLTRB(0, 0, 0, 55),
      width: 80,
      height: 80,
      child: FloatingActionButton(
        focusColor: Colors.white54,
        backgroundColor: Colors.white,
        onPressed: () {},
        child: const Icon(
          Icons.add,
          color: Colors.black,
          size: 50,
        ),
      ),

    )

output:

enter image description here

like image 43
Jahidul Islam Avatar answered Oct 14 '25 17:10

Jahidul Islam