【发布时间】:2019-12-21 15:23:48
【问题描述】:
这是 FutureBuilder:
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: postsRef
.document(userId)
.collection('userPosts')
.document(postId)
.get(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return circularProgress();
}
Post post = Post.fromDocument(snapshot.data);
return Center(
child: Scaffold(
appBar: header(context, titleText: post.description),
body: ListView(
children: <Widget>[
Container(
child: post,
)
],
),
),
);
},
);
}
引用它的show post方法:
showPost(context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PostScreen(
postId: postId,
userId: userId,
),
),
);
}
遇到错误
在 null 上调用了方法“[]”。 接收方:空 尝试调用: 相关的导致错误的小部件是: FutureBuilder file:///home/testflutter/AndroidStudioProjects/testingflutter/lib/pages/post_screen.dart:15:12
【问题讨论】:
标签: flutter dart nosuchmethoderror