您可以更改
fetchPost以返回帖子列表,例如:
Future<List<Post>> fetchPosts() async { http.Response response = await http.get('http://**********:88/WordPress/wp-json/wp/v2/posts/'); List responseJson = json.depre(response.body); return responseJson.map((m) => new Post.fromJson(m)).toList();}然后您可以
Future<List<Post>>像这样利用:
@overrideWidget build(BuildContext context) { return new FutureBuilder<List<Post>>( future: fetchPosts(), builder: (context, snapshot) { if (!snapshot.hasData) return Container(); List<Post> posts = snapshot.data; return new ListView( children: posts.map((post) => Text(post.title)).toList(), ); }, );}ListView带有一个孩子列表,就像等
Column。所以您可以使用任何包含孩子列表的小部件



