如何在按鈕樣式中使用形狀,MaterialStateProperty<OutlinedBorder> 形狀
它對我不起作用
uj5u.com熱心網友回復:
這是一個示例,您可以這樣做來更改 ElevatedButton 的形狀:
ElevatedButton.icon(
onPressed: () {
_showCustomerDialog();
},
icon: Icon(Icons.person_sharp, color: Colors.black),
label: Text('Customer 1', style: TextStyle(color: Colors.black)),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Color(0xFF10FB06)),
shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: BorderRadius.circular(40) ))
),
),
這些是可以應用的形狀類別:
- 斜面矩形邊框,
- 圓形邊框,
- 連續矩形邊框,
- MaterialStateOutlinedBorder,
- 圓角矩形邊框,
- 體育場邊界
它們都是 OutlinedBorder 的實作,它是一個抽象類,因此它們都可以將特定形狀應用于按鈕,根據需要使用任何一個。
更多資訊:https ://api.flutter.dev/flutter/painting/OutlinedBorder-class.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/449688.html
上一篇:使用SetState更新變數資料
下一篇:如何在顫動中適合列/行表影像內容
