How to set the width of a RaisedButton in Flutter?

后端 未结 20 2173
傲寒
傲寒 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条回答
  •  梦毁少年i
    2021-01-30 06:38

    You need to use an Expanded Widget. But, if your button is on a column, the Expanded Widget fills the rest of the column. So, you need to enclose the Expanded Widget within a row.

    Row(children: [
    Expanded(
      flex: 1,
      child: RaisedButton(
        child: Text("Your Text"),
          onPressed: _submitForm,
        ),
      ),),])
    

提交回复
热议问题