容器盒裝飾可以應用在里面的按鈕上嗎?例如,我試圖在提升按鈕中設定圓形邊框。它不適用于這種情況。
Container(
height: 100,
width: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
),
child: ElevatedButton(
style: ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 15)),
onPressed: () async { navigateToBasketPage(context);
},
child: const Text('My basket'),
),
),
謝謝!
uj5u.com熱心網友回復:
您可以直接設定按鈕樣式。但是如果你想Container對其子應用邊框。只需將clipBehavior: Clip.hardEdge屬性添加到您的Container.
uj5u.com熱心網友回復:
要添加decoration到您的ElevatedButton,您可以使用ElevatedButton 的style屬性,并且在該屬性中,您可以通過兩種方式應用decoration
第一的 :
ElevatedButton(
onPressed: () {},
child: Text(""),
style: ElevatedButton.styleFrom(),
)
第二 :
ElevatedButton(
onPressed: () {},
child: Text(""),
style: ButtonStyle(),
)
在第二種方法中,您必須使用MaterialStatePropety將值傳遞給欄位,而在第一種方法中,您可以以正常方式傳遞值。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/420489.html
標籤:
