我這樣使用RaisedButton:
RaisedButton(shape: RoundedRectangleBorder(borderRadius: borderRadius.round(24.0))。
onPressed: null。
padding: EdgeInsets.all(12.0)。
color: Colors.blue,
孩子。Text("Button", style: TextStyle(color: Colors.white))。
他們決定讓RaisedButton被廢棄,應該使用ElevatedButton來代替。然而,padding和shape屬性卻不見了。如何用ElevatedButton獲得同樣的效果呢?
uj5u.com熱心網友回復:
你可以在Elevated Button中使用style屬性,然后你可以使用 "ElevatedButton.styleFrom "類,在其中你會發現像padding和shape這樣的屬性:
下面是一個例子。
這里有一個例子:
ElevatedButton(
樣式。ElevatedButton.styleFrom(
primary: Colors.blue,
抬高。5,
padding: EdgeInsets.all(12.0)。
形狀。new RoundedRectangleBorder(
borderRadius: new BorderRadius.round(30.0),)。
onPressed: handler,
孩子。Text("Button", style: TextStyle(color: Colors.white))。
),
uj5u.com熱心網友回復:
試試這個代碼,希望對你有幫助,它類似于RaisedButton
。 ElevatedButton(
onPressed: () {},
樣式。ElevatedButton.styleFrom(
固定尺寸。Size(90, 15)。
形狀。RoundedRectangleBorder(
borderRadius: borderRadius.all(
Radius.round(24.0),
),
),
),
孩子。Text("ok")。
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/321025.html
標籤:

