How to create border radius of elevatedbutton in flutter

0 votes
I'm currently developing an Android app in Flutter. How can I add a rounded button?
Mar 1, 2023 in Android by Ashwini
• 5,440 points
• 41,224 views

1 answer to this question.

0 votes

To create a rounded button with border-radius in Flutter, you can use the ElevatedButton or TextButton widget and set its shape property to RoundedRectangleBorder with a BorderRadius parameter.

Here's an example using ElevatedButton:

ElevatedButton(
  onPressed: () {},
  child: Text('Button'),
  style: ElevatedButton.styleFrom(
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(20),
    ),
  ),
),

Here's an example using TextButton:

TextButton(
  onPressed: () {},
  child: Text('Button'),
  style: TextButton.styleFrom(
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(20),
    ),
  ),
),

In both examples, the BorderRadius.circular(20) parameter sets the radius of the button corners to 20 pixels. You can adjust this value to get the desired level of roundness.

You can also customize other properties of the button, such as its color and text style, using the appropriate parameters in styleFrom() method.

To know more about Flutter, join our Flutter Certification Course today.

answered Mar 1, 2023 by vishalini

Related Questions In Android

0 votes
1 answer

How to create number input field in Flutter?

Yes, Flutter has a built-in widget called ...READ MORE

answered Mar 1, 2023 in Android by vishalini
• 12,864 views
0 votes
0 answers

How to create Toast in Flutter

Can I create something similar to Toasts in Flutter? Just ...READ MORE

Mar 9, 2023 in Android by sarit
• 1,830 points
• 2,072 views
0 votes
1 answer

How to change package name in flutter?

Yes, you can change the package name ...READ MORE

answered Mar 1, 2023 in Android by vishalini
• 6,638 views