我正在尝试对Ios Simulator-Flutter上的帖子执行网格视图。启动网格查看后,就会发生以下情况:
我捕获到的主要异常的代码是(突出显示堆栈):
class _ProfileState extends State<Profile> {
final String currentUserId = currentUser?.id;
String postOrientation = "grid";
bool isLoading = false;
int postCount = 0;
**List<Post> posts = [];**
@override
void initState() {
super.initState();
getProfilePosts();
}
getProfilePosts() async {
setState(() {
isLoading = true;
});
QuerySnapshot snapshot = await postsRef
.document(widget.profileId)
.collection('userPosts')
.orderBy('timestamp', descending: true)
.getDocuments();
setState(() {
isLoading = false;
postCount = snapshot.documents.length;
**posts = snapshot.documents.map((doc) => Post.fromDocument(doc)).toList()**;
});
}
我很乐意为null错误提供任何输入信息:
[堆栈错误] [2]