How to set the width of a RaisedButton in Flutter?

后端 未结 20 2172
傲寒
傲寒 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条回答
  •  Happy的楠姐
    2021-01-30 06:36

    Use Media Query to use width wisely for your solution which will run the same for small and large screen

      Container(
                width: MediaQuery.of(context).size.width * 0.5, // Will take 50% of screen space
                child: RaisedButton(
                  child: Text('Go to screen two'),
                  onPressed: () => null
                ),
              )
    

    You can apply similar solution to SizeBox also.

提交回复
热议问题