将卡设置为Listview
我是个新手。 请帮我用卡片列表视图。 我从SQLite获取数据,并直接将其设置为listview。请让我知道如何在我的代码中添加卡。 这是我的密码将卡设置为Listview,listview,flutter,dart,Listview,Flutter,Dart,我是个新手。 请帮我用卡片列表视图。 我从SQLite获取数据,并直接将其设置为listview。请让我知道如何在我的代码中添加卡。 这是我的密码 body: FutureBuilder<List<UserModel>>( future: db.getUserModelData(), builder: (context, snapshot) { if (!snapshot.hasData) return Center(chil
body: FutureBuilder<List<UserModel>>(
future: db.getUserModelData(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return Center(child: CircularProgressIndicator());
return ListView(
children: snapshot.data
.map((user) => ListTile(
title: Text(user.name),
subtitle: Text(user.bDate),
leading: CircleAvatar(
backgroundColor: Color(
(math.Random().nextDouble() * 0xFFFFFF)
.toInt() <<
0)
.withOpacity(1.0),
child: Text(user.name[0],
style: TextStyle(
fontSize: 18.0,
color: Colors.white,
)),
),
))
.toList(),
);
},
),
body:FutureBuilder(
future:db.getUserModelData(),
生成器:(上下文,快照){
如果(!snapshot.hasData)
返回中心(子项:CircularProgressIndicator());
返回列表视图(
子项:snapshot.data
.map((用户)=>ListTile(
标题:文本(用户名),
字幕:文本(user.bDate),
领先:CircleAvatar(
背景颜色(
(math.Random().nextDouble()*0xFFFFFF)
.toInt()我已经解决了列()的问题
这是密码
return Column(
children: List.generate(snapshot.data.length, (itemIndex) {
ProfileModel product = snapshot.data[itemIndex];
return Card(
child: ListTile(
leading: SizedBox(
height: 50.0,
width: 50.0,
child: CircleAvatar(
backgroundColor: Color(
(math.Random().nextDouble() * 0xFFFFFF)
.toInt() <<
0)
.withOpacity(1.0),
child: Text(product.name[0],
style: TextStyle(
fontSize: 18.0,
color: Colors.white,
)),
)),
title: Text(product.name),
subtitle: Text(product.bDate + ', ' + product.mobile),
));
}),
);
返回列(
子项:List.generate(snapshot.data.length,(itemIndex){
ProfileModel product=snapshot.data[itemIndex];
回程卡(
孩子:ListTile(
引导:SizedBox(
身高:50.0,
宽度:50.0,
孩子:圆环星(
背景颜色(
(math.Random().nextDouble()*0xFFFFFF)
.toInt()你能解释一下你需要什么吗?@SelimKundakçıoğlu我想把这张卡添加到我的列表中