How to set the width of a RaisedButton in Flutter?

后端 未结 20 1910
傲寒
傲寒 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:37

    Simply use FractionallySizedBox, where widthFactor & heightFactor define the percentage of app/parent size.

    FractionallySizedBox(
    widthFactor: 0.8,   //means 80% of app width
    child: RaisedButton(
      onPressed: () {},
      child: Text(
        "Your Text",
        style: TextStyle(color: Colors.white),
      ),
      color: Colors.red,
    )),
    

提交回复
热议问题