Flutter 从Cloud Firestore获取多个采集数据,以使用唯一的屏幕
嗨,伙计们。 我有一个关于从CloudFirestore获取多个收集数据并获取到Flatter小部件的问题 我有我的变量类:Flutter 从Cloud Firestore获取多个采集数据,以使用唯一的屏幕,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,嗨,伙计们。 我有一个关于从CloudFirestore获取多个收集数据并获取到Flatter小部件的问题 我有我的变量类: class IfUserProfile { static int id; static String name; static String lastname; static String email; static String blog; } 例如,对于BLOG字符串,我将其放入一个TextFormField,并正确地进入cloud fire
class IfUserProfile {
static int id;
static String name;
static String lastname;
static String email;
static String blog;
}
例如,对于BLOG字符串,我将其放入一个TextFormField,并正确地进入cloud firestore:
CollectionReference addUrl = FirebaseFirestore.instance.collection('blogAddress');
Future<void> createRecord() {
var firebaseUser = FirebaseAuth.instance.currentUser;
return addUrl
.doc(firebaseUser.uid)
.set({
'webAddress': IfUserProfile.blog,//this is a variable Class ABOVE
})
.then((value) => print("User Added"))
.catchError((error) => print("Failed to add user: $error"));
}
CollectionReference addUrl=FirebaseFirestore.instance.collection('blogAddress');
未来的createRecord(){
var firebaseUser=FirebaseAuth.instance.currentUser;
返回地址URL
.doc(firebaseUser.uid)
.设置({
“webAddress”:IfUserProfile.blog,//这是上面的变量类
})
。然后((值)=>打印(“用户添加”))
.catchError((error)=>打印(“添加用户失败:$error”);
}
我需要将这些变量从类中获取到一个屏幕中,在那里我构建了一个FutureBuilder
class _InfluencerProfileScreenState extends State<InfluencerProfileScreen> {
CollectionReference blogAddress =
FirebaseFirestore.instance.collection('blogAddress');
var firebaseUser = FirebaseAuth.instance.currentUser;
class\u影响者档案屏幕状态扩展状态{
CollectionReference博客地址=
FirebaseFirestore.instance.collection('blogAddress');
var firebaseUser=FirebaseAuth.instance.currentUser;
及
child:FutureBuilder(
future:blogAddress.doc(firebaseUser.uid).get(),
生成器:(BuildContext上下文,
异步快照(快照){
if(snapshot.hasError){
返回文本(“出错”);
}
if(snapshot.connectionState==connectionState.done){
映射数据=snapshot.data.data();
返回列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
大小盒子(
身高:30,
),
文本(${data['webAddress']}),样式:TextStyle(颜色:Colors.white),
圆形(
半径:50,
背景颜色:Colors.black12,
孩子:圆环星(
背景颜色:Colors.black12,
背景图片:AssetImage(
CurrentInfluenceUser.imageUrl),
半径:47,
),
),
大小盒子(
身高:8,
),
RichText(
text:TextSpan(子项:[
TextSpan(
文本:“${data['name']}”,
很明显,我只是得到了blogAddress集合,但我需要得到其他集合,因为我还有一些其他字段需要填充。。
有什么意见吗
child: FutureBuilder<DocumentSnapshot>(
future: blogAddress.doc(firebaseUser.uid).get(),
builder: (BuildContext context,
AsyncSnapshot<DocumentSnapshot> snapshot) {
if (snapshot.hasError) {
return Text("Something went wrong");
}
if (snapshot.connectionState == ConnectionState.done) {
Map<String, dynamic> data = snapshot.data.data();
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 30,
),
Text(" ${data['webAddress']}",style: TextStyle(color: Colors.white),),
CircleAvatar(
radius: 50,
backgroundColor: Colors.black12,
child: CircleAvatar(
backgroundColor: Colors.black12,
backgroundImage: AssetImage(
currentInfluencerUser.imageUrl),
radius: 47,
),
),
SizedBox(
height: 8,
),
RichText(
text: TextSpan(children: [
TextSpan(
text: "${data['name']}",