我正在尝试在我的flutter应用程序中获得我的wordpress帖子,我正在成功地获得帖子。现在的问题是只显示了10个帖子。
Future<List> fetchWpCats() async{
final response = await http.get(
Uri.parse('https://rashtrasandeshnews.com/wp-json/wp/v2/posts'),
headers: {"Accept": "application/json"}
);
var convertedDatatoJson = jsonDecode(response.body);
return convertedDatatoJson;
}
这是我的列表视图,其中我只得到10个项目。
FutureBuilder(
future: fetchWpPosts('posts'),
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.data != null) {
return ListView.builder(
itemCount: snapshot.data.length!,
itemBuilder: (context, index) {
Map JSON = snapshot.data![index];
return InkWell(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PostDetails(
id: JSON['id'],
title: JSON['title']['rendered'],
content: JSON['content']['rendered'],
image: JSON['_embedded']
['wp:featuredmedia'][0]
["source_url"],
))),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
elevation: 10,
shadowColor: Colors.pink,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Html(
data: JSON['title']['rendered'],
style: {
"body": Style(
fontSize: FontSize(18.0),
fontWeight: FontWeight.bold,
textAlign: TextAlign.center),
},
),
],
),
),
),
);
},
);
}
return Center(
child: CircularProgressIndicator(
backgroundColor: Colors.pink,
));
},
),
现在,请为我提供详细的说明/步骤,以便我可以获取所有帖子。
暂无答案!
目前还没有任何答案,快来回答吧!