flutter 里面 RaisedButton、FloatingActionButton、FlatButton、OutlineButton 中四個button都無高度設置,如下用RaisedButton舉例:
處理辦法第一種:沒有高度就用一個有高度的 View 來加載 Container,於是有了
new Container(
height: 60.0,
child: new RaisedButton(onPressed: (){},
child: new Text("測試Buton的寬度"), color: Colors.deepOrange, ), ),
Container設置高度就實現 ,但是Container的寬度不會占滿 只會隨着里面字體的寬度顯示。 接下來使用 pading 實現Button的高度
處理辦法二,使用pading來實現 Button的高度
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: (){
print(" 我點擊了 Padding 下的 RaisedButton"); }, //通過控制 Text 的邊距來控制控件的高度 child: new Padding(padding: new EdgeInsets.fromLTRB(10.0, 10.0, 0.0, 10.0), child: new Text("Padding測試Buton的寬度"), ), color: Colors.deepOrange, ), ), ], ), ),
pading設置高度,寬度會占滿