API占位符
一个可组合的、轻量级的包,当你需要一些虚假数据时可以使用它作为占位符。
使用此包,您可以获得一些著名的API响应,例如用户、帖子、评论、照片、待办事项等。
在使用真实的API端点之前,可以将其用于原型设计和测试。
用法
要使用此插件,请将api_placeholder添加为pubspec.yaml中的依赖项。
void getFakeUsers() async {
String x = await ApiPlaceholder().getUsers()
// Return a list of users
print(x);
}
void getFakePhotos() async {
String x = await ApiPlaceholder().getPhotos(id: 4);
// When Id is passed, it returns only one photo with that particular Id
print(x);
}
void getFakeTodos() async {
String x = await ApiPlaceholder().getTodos(limit: 5);
// When limit is passed, it limits the number od todos.
print(x);
}
附加信息
欢迎大家为此包做出贡献或提交任何问题。
Github仓库: https://github.com/ViAsmit/api_placeholder_package