[英]RoundedRectangleBorder not working with ListTile nor Card in flutter
我有這個自定義的 function,它返回一張包含 ListTile 的卡片。 我在造型上遇到了一些麻煩。 我想將圓角應用於卡片或 ListTile(我只想要圓角),如下所示。 它對我不起作用。
我嘗試將 cardTheme 應用於單獨文件中自定義主題中的所有卡片但不起作用,在我下面的代碼中,我希望卡片在用戶按下時顯示為藍色,並顯示默認的波紋效果但不能不。 也無法在卡片周圍應用藍色邊框。 我的造型出了點問題
Card myCardListTile(MyScreen myScreen, BuildContext context) {
return Card(
child: ListTile(
contentPadding: EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: kColorOxfordBlue, width: 12)),
// focusColor: kColorOxfordBlue,
// hoverColor: kColorOxfordBlue,
onTap: () {
Navigator.pushNamed(context, myScreen.route);
},
title: Text(
myScreen.title,
style: Theme.of(context).textTheme.headline6,
// TextStyle(),
),
),
);
Class AppTheme {
static final ThemeData lightTheme = ThemeData(
cardTheme: CardTheme(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18.0)),
),
);}
在 main.dart 我使用了 AppTheme.lightTheme
return MaterialApp(
theme: AppTheme.lightTheme,
// code
是否必須使用列表視圖? 因為您可以使用其他小部件,例如帶有圓角的卡片內的容器。 例如
return Card(
elevation: 10.0,
color: Colors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: Container(
padding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('something here'),
SizedBox(width: 4.0),
Text('something other here'),
],
),
),
);
您可以根據需要自定義容器,希望對您有所幫助..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.