Flutter中RaisedButton、FloatingActionButton、FlatButton、OutlineButton四个按钮等控件均无高度设置,解决方式如下:
使用有高度的Container包裹
new Container(
height: 40.0,
child: new RaisedButton(onPressed: () {},
child: new Text("AppBlog.CN"),
color: Colors.deepOrange,
),
),
Container设置高度即可实现,Container的宽度不会占满父容器,只会随着里面字体的宽度显示
使用Pading包裹
new Padding(padding: new EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
child: new Row(
children: <Widget>[
new Expanded(
child: new RaisedButton(
onPressed: () {},
//通过控制边距来设置控件的高度
child: new Padding(padding: new EdgeInsets.fromLTRB(10.0, 10.0, 0.0, 10.0),
child: new Text("AppBlog.CN"),
),
color: Colors.deepOrange,
),
),
],
),
),
Padding设置高度,宽度会占满