Search code examples
fluttermaterial-uimaterial-design

How do I make Flutter's Material Design 3 FAB as round as Material Design 2?


The code I tried is the following code.

FloatingActionButton(
        onPressed: () {},
        backgroundColor: Colors.transparent,
        elevation: 0,
        child: Container(
          decoration: const BoxDecoration(
            shape: BoxShape.circle,
            color: Colors.blue,
          ),
          constraints: const BoxConstraints.expand(),
          child: const Icon(
            Icons.add,
            color: Colors.white,
          ),
        ),
      )
    

enter image description here

This image is the code above.

I was able to make it look almost the same, but if there is a better way to do it, please let me know.


Solution

  • In this case, the FloatingActionButton docs show the shape property :)

    floatingActionButton: FloatingActionButton(
      shape: const CircleBorder(),
      // ...
    ),