Dart 在我的颤振代码中添加字幕
我有一个颤振代码:Dart 在我的颤振代码中添加字幕,dart,flutter,Dart,Flutter,我有一个颤振代码: body: StreamBuilder( stream: Firestore.instance.collection('Doctors').snapshots(), builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) { if (!snapshot.hasData)
body: StreamBuilder(
stream: Firestore.instance.collection('Doctors').snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData)
return const Center(child: CircularProgressIndicator());
return ListView(
padding: const EdgeInsets.only(top: 8.0),
children:
snapshot.data.documents.map((DocumentSnapshot document) {
return new Card(
child: new Container(
padding: EdgeInsets.all(10.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
CircleAvatar(
backgroundColor: Colors.grey,
backgroundImage:
new NetworkImage("${document['Picture']}"),
radius: 40.0,
),
SizedBox(width: 10.0,
),
Text(
document['Name'],
)
],
),
),
);
}).toList(),
);
},
),
),
正文:StreamBuilder(
流:Firestore.instance.collection('Doctors').snapshots(),
建设者:
(BuildContext上下文,异步快照){
如果(!snapshot.hasData)
返回常量中心(子项:CircularProgressIndicator());
返回列表视图(
填充:仅限常量边集(顶部:8.0),
儿童:
snapshot.data.documents.map((DocumentSnapshot文档){
归还新卡(
子容器:新容器(
填充:所有边缘设置(10.0),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
圆形(
背景颜色:颜色。灰色,
背景图片:
新网络图像(${document['Picture']}”),
半径:40.0,
),
尺寸框(宽度:10.0,
),
正文(
文件['Name'],
)
],
),
),
);
}).toList(),
);
},
),
),
我需要在连接到文本的文本(文档['Name'])下插入另一个文本作为字幕,但我不能这样做,您能帮我归还新卡吗(
return new Card(
child: new Container(
padding: EdgeInsets.all(10.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
CircleAvatar(
backgroundColor: Colors.grey,
backgroundImage: new NetworkImage("${document['Picture']}"),
radius: 40.0,
),
SizedBox(
width: 10.0,
),
Column(
children: <Widget>[
Text(document['name']),
Text('subtitle'),
],
)
],
),
),
);
子容器:新容器(
填充:所有边缘设置(10.0),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
圆形(
背景颜色:颜色。灰色,
背景图像:新的网络图像(${document['Picture']}),
半径:40.0,
),
大小盒子(
宽度:10.0,
),
纵队(
儿童:[
文本(文档['name']),
文本(“副标题”),
],
)
],
),
),
);
您可以使用类似的方法。退回新卡(
子容器:新容器(
填充:所有边缘设置(10.0),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
圆形(
背景颜色:颜色。灰色,
背景图像:新的网络图像(${document['Picture']}),
半径:40.0,
),
大小盒子(
宽度:10.0,
),
纵队(
儿童:[
文本(文档['name']),
文本(“副标题”),
],
)
],
),
),
);
您可以使用类似的方法。这就是您想要的,只需添加
正文:StreamBuilder(
流:Firestore.instance.collection('Doctors').snapshots(),
建设者:
(BuildContext上下文,异步快照){
如果(!snapshot.hasData)
返回常量中心(子项:CircularProgressIndicator());
返回列表视图(
填充:仅限常量边集(顶部:8.0),
儿童:
snapshot.data.documents.map((DocumentSnapshot文档){
归还新卡(
子容器:新容器(
填充:所有边缘设置(10.0),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
圆形(
背景颜色:颜色。灰色,
背景图片:
新网络图像(${document['Picture']}”),
半径:40.0,
),
尺寸框(宽度:10.0,
),
新ListTile(
标题:文本(文件['name']),
字幕:文本(“字幕”),
],
),
),
);
}).toList(),
);
},
),
),
这就是您想要的,只需添加
正文:StreamBuilder(
流:Firestore.instance.collection('Doctors').snapshots(),
建设者:
(BuildContext上下文,异步快照){
如果(!snapshot.hasData)
返回常量中心(子项:CircularProgressIndicator());
返回列表视图(
填充:仅限常量边集(顶部:8.0),
儿童:
snapshot.data.documents.map((DocumentSnapshot文档){
归还新卡(
子容器:新容器(
填充:所有边缘设置(10.0),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
圆形(
背景颜色:颜色。灰色,
背景图片:
新网络图像(${document['Picture']}”),
半径:40.0,
),
尺寸框(宽度:10.0,
),
新ListTile(
标题:文本(文件['name']),
字幕:文本(“字幕”),
],
),
),
);
}).toList(),
);
},
),
),
我认为您正在尝试显示数据列表,但我不确定您是否真的需要卡片样式,因为您的卡片没有间隙。
对于您的设计,您可以使用带有前导的列表平铺
body: StreamBuilder(
stream: Firestore.instance.collection('Doctors').snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData)
return const Center(child: CircularProgressIndicator());
return ListView(
padding: const EdgeInsets.only(top: 8.0),
children:
snapshot.data.documents.map((DocumentSnapshot document) {
return new Card(
child: new Container(
padding: EdgeInsets.all(10.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
CircleAvatar(
backgroundColor: Colors.grey,
backgroundImage:
new NetworkImage("${document['Picture']}"),
radius: 40.0,
),
SizedBox(width: 10.0,
),
new ListTile(
title: Text(document['name']),
subtitle: Text('subtitle'),
],
),
),
);
}).toList(),
);
},
),
),
return new Card(
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.grey,
backgroundImage: new NetworkImage("${document['Picture']}"),
radius: 40.0,
),
title: Text(document['name']),
subtitle: Text('subtitle'),
),
);
return ListTile(
leading: CircleAvatar(
backgroundColor: Colors.grey,
backgroundImage: new NetworkImage("${document['Picture']}"),
radius: 40.0,
),
title: Text(document['name']),
subtitle: Text('subtitle'),
);
title: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Title",
style: TextStyle(color: Colors.white, fontSize: 16.0),
),
Text(
'Sub Title',
style: TextStyle(color: Colors.white, fontSize: 14.0),
),
]),