【发布时间】:2019-01-31 11:46:15
【问题描述】:
如何制作像这样的小部件 或卡片列表
[![在此处输入图片描述][2]][2]
【问题讨论】:
-
您可以输入您的代码来检查您的预付款。
如何制作像这样的小部件 或卡片列表
[![在此处输入图片描述][2]][2]
【问题讨论】:
这将生成您所需的 UI,根据您的要求进行装饰
Widget build(BuildContext context) {
return new Container(
alignment: Alignment.centerLeft,
margin: new EdgeInsets.all(8.0),
padding: new EdgeInsets.all(8.0),
height: 150.0,
decoration: new BoxDecoration(
color: Colors.lightBlue,
borderRadius: new BorderRadius.all(new Radius.circular(10.0)),
boxShadow: [new BoxShadow(color: Colors.black54, offset: new Offset(2.0, 2.0),
blurRadius: 5.0)]
),
child: new Row(children: <Widget>[
new CircleAvatar(backgroundColor: Colors.white70,radius: 50.0,),
new Expanded(child: new Padding(padding: new EdgeInsets.only(left: 8.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text('Hot Pot', style: new TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),),
new Row(children: <Widget>[
new Icon(Icons.star, color: Colors.white,),
new Icon(Icons.star, color: Colors.white,),
new Icon(Icons.star, color: Colors.white,),
new Icon(Icons.star_half, color: Colors.white,),
new Icon(Icons.star_border, color: Colors.white,),
],),
new Wrap(spacing: 2.0,children: <Widget>[
new Chip(label: new Text('Hot')),
new Chip(label: new Text('Hot')),
new Chip(label: new Text('Hot')),
],)
],),))
],),
);
}
【讨论】:
看看这个question。
对于背景图片,使用Container 和BoxDecoration。对于左侧的图像,请使用 Image.asset 小部件。
【讨论】: