Change Border’s Color, Radius, Width of OutlinedButton in Flutter

The OutlinedButton in Flutter is a button with a border around it. The border color and width can be customized. We will use style property to modify properties of a ButtonStyle like color, radius, and width. OutlinedButton.style takes a ButtonStyle object as an argument.

The following code snippet shows how to change the Border’s Color, Radius, and Width of an OutlinedButton in Flutter.

OutlinedButton(
                        style: OutlinedButton.styleFrom(
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(16.0),
                          ),
                          side: const BorderSide(width: 2, color: Colors.green),
                        ),
                        onPressed: () {},
                        child: Text('OutlinedButton'),
                      ),
OutlinedButton(
                        style: ButtonStyle(
                          shape: MaterialStateProperty.resolveWith<OutlinedBorder?>((states) {
                            if (states.contains(MaterialState.pressed)) {
                              return RoundedRectangleBorder(borderRadius: BorderRadius.circular(0));
                            } else {
                              return RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0));
                            }
                          }),
                        ),
                        onPressed: () {},
                        child: Text('OutlinedButton with state'),
                      )

Circular OutlinedButton:

OutlinedButton(
                        style: OutlinedButton.styleFrom(
                          shape: const CircleBorder(),
                          side: const BorderSide(width: 2, color: Colors.green),
                        ),
                        onPressed: () {},
                        child: Text('OutlinedButton'),
                      )

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close