【发布时间】:2020-09-08 21:08:35
【问题描述】:
class Profile {
final List<String> photos;
final String name;
final int age;
final String education;
final String bio;
final int distance;
Profile({
this.photos,
this.name,
this.age,
this.education,
this.bio,
this.distance
});
}
class _MainControllerState extends State<MainController> {
static List<Profile> demoProfiles = fetchData();
static fetchData() async{
final db = await Firestore.instance;
List<Profile> list = [];
db.collection("users").getDocuments().then((querySnapshot){
querySnapshot.documents.forEach((document) {
list.add(Profile(
photos: document['photoUrl'],
name: document['photoUrl'],
age: document['photoUrl'],
distance: document['photoUrl'],
education: document['photoUrl']
));
});
});
return list;
}
final MatchEngine matchEngine = MatchEngine (
matches:demoProfiles.map((Profile profile) => Match(profile:
profile)).toList()
);
我是新来的颤振。 当我运行我的代码时,我得到了错误:类型'Future'不是'List'类型的子类型。如果我改变屏幕,我会得到错误:NoSuchMethodError:方法'map'被调用为null。我该如何解决? 谢谢你帮助我。
【问题讨论】:
标签: flutter dart google-cloud-firestore