7

I am not able to any sample for creating a circular button like FloatingActionButton? Is there any way to create it?

Below code creates a rectangular button, is there any for Circular Button?

shape: RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0))

3 Answers 3

10

You can use the MaterialButton widget.
It's shape field can be set to CircleBorder value and that will give you a circular button.

For example, I've modified the code of one of my projects views where I have rounded rectangle buttons to make one of them circular:

Container(
  width: 80,
  height: 80,
  child: MaterialButton(
    shape: CircleBorder(
              side: BorderSide(
                width: 2,
                color: Colors.red,
                style: BorderStyle.solid,
              ),
    ),
    child: Text("Login"),
    color: Colors.teal,
    textColor: Colors.amber,
    onPressed: (){},
  ),
),

Screenshot:
enter image description here

Sign up to request clarification or add additional context in comments.

Comments

3
Container(
                      width: 90,
                      height: 90,
                      child: RaisedButton(onPressed: (){
                      },
                        color: Colors.deepOrange,  
                        textColor: Colors.white,
                        shape: CircleBorder(side: BorderSide.none),
                        child: Text('Login',style: TextStyle(
                            fontSize: 20.0
                        ),
                        ),
                      ),
                    )

Comments

2

We can create a circular button by FloatingActionButton widget.

 return Container(
      alignment: Alignment.center,
        child: new SizedBox(
      child: FloatingActionButton(
          backgroundColor: Colors.red,
          child: null,
          onPressed: () {
            print("Cliked");
          },)
    ));
  }

Output:

enter image description here

2 Comments

this is not the only solution as you can see from my answer
As per flutter docs: Use at most a single floating action button per screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.