【发布时间】:2021-08-20 19:43:45
【问题描述】:
我有一个屏幕,其中显示了用户列表,使用流生成器从 firestore 检索用户数据。
StreamBuilder(
stream: Collection
.where('WorkType', isEqualTo: widget.worktype)
.snapshots(),
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
return Container(
height: 600,
child: ListView.builder(
itemCount: snapshot.data.docs.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 100,
child: GestureDetector(
onTap: () {
//Navigate to Screen two
},
child: Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
snapshot.data.docs[index].data()['Name'],
style: kRobotoSlab.copyWith(
fontSize: 20)),
Text(
snapshot.data.docs[index]
.data()['Address'],
style: kRobotoSlab.copyWith(
fontSize: 15),
),
Text(
snapshot.data.docs[index]
.data()['Phone Number'],
style: kRobotoSlab.copyWith(
fontSize: 15),
),
],
),
),
),
),
),
);
}),
);
} else if (snapshot.hasError) {
return Text(snapshot.error.toString());
} else {
return CircularProgressIndicator();
}
},
),
我希望一旦用户点击卡片,它将导航到屏幕 2,该屏幕将显示用户个人资料以及从 firestore 检索到的数据
例如Card 1 : Name => Samia Address=> USA Number=> 4659848668 用户将按下它,它将导航到带有 Samia 信息的屏幕 2。
我怎样才能实现它?
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore