None of the Flutter buttons seem to provide a way to change the corner radius of the button rectangle. There's a shape property but I have no idea how to use it.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 4 − Add the following code to res/drawable/mybutton.
In Flutter, the Container() widget is used for styling your widget. Using the Container() widget, you can set a border or rounded corner of any widget. If you want to set any type of styling and set the decoration, put that widget into the Container() widget. That provides many properties to the decoration.
To quickly add a border radius to all instances of a component, create a custom theme and add an overrides section. To create a custom theme, use the createMuiTheme hook. Then import that theme at a high level in your component and wrap all subcomponents in a ThemeProvider that uses that theme.
ElevatedButton has style Property so we can use the styleFrom method should be used to change the default style of the elevated button. We can change the border color using BorderSide class. ElevatedButton( onPressed: () {}, style: ElevatedButton. styleFrom( side: BorderSide( width: 5.0, color: Colors.
You can change the radius from the shape
property, and give it a RoundedRectangleBorder
, here you can play with the border radius.
You will get the rounded corner only in topRight
,topLeft
and bottomRight
in the below example:
RaisedButton(
onPressed: () {},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25.0),
topLeft: Radius.circular(25.0),
bottomRight: Radius.circular(25.0),
),
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With