【发布时间】:2020-09-09 01:25:02
【问题描述】:
class Profile {
final List<String> photos;
final String name;
......
Profile({
this.photos,
this.name,
......
});
}
final List<Profile> demoProfiles = [
Profile (
photos: [
"https:...",
],
name: "Fatih",
age: 22,
distance: 4,
education: "Hacettepe University"
),
Profile (
photos: [
"https:...",
"https:...",
],
name: "Elysium",
age: 23,
distance: 2,
bio: "Test bio"
)
];
如何从 Firestore 检索数据,然后更新我的 List demoProfiles 并在我的 main_controller.dart 中使用它?我真的是 Flutter 新手,谁能帮帮我?谢谢。
final MatchEngine matchEngine = MatchEngine (
matches:demoProfiles.map((Profile profile) => Match(profile: profile)).toList()
);
【问题讨论】:
-
我试图将我的 main_controller.dart 更改为上面的屏幕截图,但它返回了错误:type 'Future
' is not a subtype of type 'List -
你能收到来自firebase的数据吗?
-
是的,我试着把数据打印出来,没关系
-
那么现在有什么问题?
-
它返回了一个错误:“Future
- >”类型的值不能分配给“List
”类型的变量。如果我在其他页面之间导航和主控制器,它返回错误:NoSuchMethodError: The method 'map' was called on null
标签: firebase flutter dart google-cloud-firestore future