我正在尝试使用颤振来构建卡,该卡看起来像下面所示的概念,但是我却得到了它。
这是Dart中的卡片小部件代码:
@override
Widget build(BuildContext context) {
return Center(
child: Card(
margin: EdgeInsets.symmetric(horizontal: 14.0),
color: Colors.white,
elevation: 6.0,
child: InkWell(
splashColor: Colors.blue.withAlpha(30),
onLongPress: () {_copy();},
onTap: () {},
child: Container(
child: Padding(
padding: EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
Text(widget.cardTitle),
Spacer(),
ButtonBar(
children: <Widget>[
new IconButton(
icon: Icon(CardsIcons.arrows_ccw, color: primaryDark,),
onPressed: () {_refresh();},
),
new IconButton(
icon: Icon(CardsIcons.heart_empty, color: Colors.redAccent,),
onPressed: () {_bookmark();},
),
],
),
SizedBox(height: 24.0,),
Text(
widget.cardContent,
),
],
),
),
),
),
),
);
}
这是我当前得到的输出
这是所需的输出
答案 0 :(得分:2)
您的结构很接近,但是要获得布局,您需要先将所有内容包装在Column小部件中,然后再将包含行的子项包装,然后再包含文本。
下面的代码应该是一个好的开始,您只需要调整填充/文本样式等就可以像您的模型一样
@override
Widget build(BuildContext context) {
return Center(
child: Card(
margin: EdgeInsets.symmetric(horizontal: 14.0),
color: Colors.white,
elevation: 6.0,
child: InkWell(
splashColor: Colors.blue.withAlpha(30),
onLongPress: () {_copy();},
onTap: () {},
child: Container(
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Text(widget.cardTitle),
Spacer(),
ButtonBar(
children: <Widget>[
new IconButton(
icon: Icon(CardsIcons.arrows_ccw, color: primaryDark,),
onPressed: () {_refresh();},
),
new IconButton(
icon: Icon(CardsIcons.heart_empty, color: Colors.redAccent,),
onPressed: () {_bookmark();},
),
],
),
SizedBox(height: 24.0,),
],
),
Container(
child: Text(
widget.cardContent,
),
),
],
),
),
),
),
),
);
}