How To Change Flutter OutlinedButton Border Radius [Flutter Easy Guide]

flutter outlinedbutton border radius

In this tutorial, we’ll learn how to properly customize Flutter outlinedButton border radius by using practical Flutter code examples.

Introduction: Flutter OutlinedButton Border Radius

As the name suggests, it specifies the process of making the edges/corners of outlinedButton circular. Let’s first see the default shape of corners. After that, we’ll make them circular using practical code examples.

Default Flutter OutlinedButton Shape

For that, we’ve to implement a simple Flutter outlinedButton widget. We also have given it a background color. See below code:

OutlinedButton(
                onPressed: () {},
                style: OutlinedButton.styleFrom(
                        backgroundColor: Colors.blue,
                     ),
                    child: Text(
                      'Flutter Outlined Button',
                      style: TextStyle(color: Colors.white),
                    ))

flutter outlinedbutton default border radius

Above image shows the default border radius of outlinedButton.

Customizing Flutter OutlinedButton Border Radius (Multiple Examples)

In order to do that, we’ve to use the style constructor of our Flutter outlinedButton widget and pass OutlinedButton.styleFrom( ).

After that, we’ve to use its shape constructor and pass it round rectangle border widget. This widget has a border radius constructor which can take different methods. See below list:

  1. BorderRadius.circular()
  2. BorderRadius.horizontal()
  3. BorderRadius.vertical()
  4. BorderRadius.only()

Border Radius Circular

If we want to make each and every edge of Flutter outlinedButton circular and all of the same value, then we can use the below code:

style: OutlinedButton.styleFrom(
           backgroundColor: Colors.blue,
           shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(15)))
flutter outlinedbutton border radius circular
If we want some edges to have a different radius value then we can use the copyWith method. See below code:
flutter outlinedbutton border radius circular shape
 shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(7).copyWith(
                  bottomLeft: Radius.circular(57),
                  topRight: Radius.circular(23)))

Border Radius Horizontal

If we want to give top right and bottom right edge a same value and top left and bottom left a same value, then use the below code:

flutter outlinedbutton border radius horizontal

 shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.horizontal(
                  right: Radius.circular(25),
                  left: Radius.circular(9)))
We can use copyWith method here as well.

Border Radius Vertical

If you want to give top right and top left edge a same value and bottom right and bottom left edge a same value, then use the below code:

flutter outlinedbutton border radius vertical

 shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.vertical(
                  top: Radius.circular(25),
                  bottom: Radius.circular(11)))
We can use copyWith method here as well.

Border Radius Only

If we want to provide each edge of Flutter outlinedButton with different/same value, then use the below code:

flutter outlinedbutton border radius only

shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.only(
                 topRight: Radius.circular(7),
                 topLeft: Radius.circular(21),
                 bottomLeft: Radius.circular(41),
                 bottomRight: Radius.circular(11),
                    ))
We can use copyWith method here as well but it won’t be a good practice.
So this is how we can customize Flutter outlinedButton border radius.
We’ve discussed it in detail so you can have a better idea of how to customize the border radius of Flutter outlinedButton widget. Hope you like this post.
The complete source code of customized Flutter outlinedButton border radius is given in the below section.

Custom Flutter OutlinedButton Border Radius Source Code

flutter outlinedbutton border radius only

import 'package:flutter/material.dart';
void main() {
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Homepage(),
    );
  }
}
class Homepage extends StatefulWidget {
  @override
  State<Homepage> createState() => _HomepageState();
}
class _HomepageState extends State<Homepage> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
            body: Center(
                child: OutlinedButton(
                    onPressed: () {},
                    style: OutlinedButton.styleFrom(
                        backgroundColor: Colors.blue,
                        shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.only(
                          topRight: Radius.circular(7),
                          topLeft: Radius.circular(21),
                          bottomLeft: Radius.circular(41),
                          bottomRight: Radius.circular(11),
                        ))),
                    child: Text(
                      'Flutter Outlined Button',
                      style: TextStyle(color: Colors.white),
                    )))));
  }
}

Conclusion

To conclude this tutorial, now you’ve a detailed and in-depth practical knowledge of how to customize Flutter outlinedButton border radius. I’d love to have your feedback on this post.

I’d also love to see you visit my other tutorials on Flutter app development and Python programming as well. Thank you for reading this post.

Leave a Comment

Your email address will not be published.