【发布时间】:2019-10-09 21:37:04
【问题描述】:
我正在尝试匹配这个设计
点击卡片应该展开
我不能使用包裹扩展牌的卡片,因为扩展牌基本上只有一行,我试图按照这个例子 flutter_catalog
我在谷歌上搜索了很多,但找不到我想要实现的示例,我在 stackoverflow 上能找到的最接近的东西是这个 other question 是否有可折叠/可扩展的卡片?
【问题讨论】:
我正在尝试匹配这个设计
点击卡片应该展开
我不能使用包裹扩展牌的卡片,因为扩展牌基本上只有一行,我试图按照这个例子 flutter_catalog
我在谷歌上搜索了很多,但找不到我想要实现的示例,我在 stackoverflow 上能找到的最接近的东西是这个 other question 是否有可折叠/可扩展的卡片?
【问题讨论】:
您绝对可以使用 Card 包装 ExpansionTile。 ExpansionTile 有一个 title 属性,它接受一个 Widget,因此您可以将任何您想要的 Widget 传递给它。
凌乱的示例代码,但希望你能明白:
class ExpandedTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(15.0))),
elevation: 2,
margin: EdgeInsets.all(12.0),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ExpansionTile(
backgroundColor: Colors.white,
title: _buildTitle(),
trailing: SizedBox(),
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
Text("Herzlich Willkommen"),
Spacer(),
Icon(Icons.check),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
Text("Das Kursmenu"),
Spacer(),
Icon(Icons.check),
],
),
)
],
),
),
);
}
Widget _buildTitle() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Text("MODUL 1"),
Spacer(),
Text("Mehr"),
],
),
Text("Kursubersicht"),
Row(
children: <Widget>[
Text("6 Aufgaben"),
Spacer(),
FlatButton.icon(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(15.0))),
padding: EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
color: Colors.blue,
textColor: Colors.white,
onPressed: () {},
icon: Icon(Icons.play_arrow),
label: Text("Fortsetzen"),
),
],
),
],
);
}
}
生产
当被点击时
【讨论】: