Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set rounded border to a MaterialButton on Flutter?

I'm trying set rounded border to my MaterialButton, to do it I'm setting a RoundedRectangleBorder to shape attribute's MaterialButton, the problem is that it's not have effect.

Code:

  Widget _showNeedHelpButton() {
    return new Padding(      
      padding: EdgeInsets.fromLTRB(0.0, 5.0, 0.0, 0.0),
      child: new MaterialButton(
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20.0))),
        elevation: 5.0,
        minWidth: 200.0,
        height: 35,
        color: Color(0xFF801E48),
        child: new Text('Preciso de ajuda',
            style: new TextStyle(fontSize: 16.0, color: Colors.white)),
        onPressed: () {
          setState(() {
            _isNeedHelp = true;
          });
        },
      ),
    );
  }

Result:

enter image description here

like image 355
Augusto Avatar asked Feb 22 '19 13:02

Augusto


People also ask

How do you give a round border to a container in Flutter?

If you want border for all the corners you can use like bellow. Container( decoration: BoxDecoration( color: Colors. white, borderRadius: BorderRadius.

How do you give the rounded border to the elevated button in Flutter?

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.


1 Answers

MaterialButton(
        child: Text('My Button'),
        height: 40,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10.0),
        ),
)

RoundedRectangleBorder will help you https://api.flutter.dev/flutter/painting/RoundedRectangleBorder-class.html

like image 121
Necessary Lion Avatar answered Sep 23 '22 14:09

Necessary Lion