How to set the width of a RaisedButton in Flutter?

后端 未结 20 2167
傲寒
傲寒 2021-01-30 06:01

I have seen that I can\'t set the width of a RaisedButton in Flutter. If I have well understood, I should put the RaisedButton into a SizedBox

20条回答
  •  野性不改
    2021-01-30 06:44

    you can do as they say in the comments or you can save the effort and work with RawMaterialButton . which have everything and you can change the border to be circular and alot of other attributes. ex shape(increase the radius to have more circular shape)

    shape: new RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),//ex add 1000 instead of 25
    

    and you can use whatever shape you want as a button by using GestureDetector which is a widget and accepts another widget under child attribute. like in the other example here

    GestureDetector(
    onTap: () {//handle the press action here }
    child:Container(
    
                  height: 80,
                  width: 80,
                  child:new Card(
    
                    color: Colors.blue,
                    shape: new RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
                    elevation: 0.0,                
                  child: Icon(Icons.add,color: Colors.white,),
                  ),
                  )
    )
    

提交回复
热议问题