【发布时间】:2020-06-01 06:59:39
【问题描述】:
我正在使用 Chopper 调用 api,我想得到结果 json, 这是我要调用的 API [https://api.jsonbin.io/b/5e1219328d761771cc8b9394]
我想问一下这种问题怎么解决,
未处理的异常:NoSuchMethodError:方法 在 null 上调用了“inheritFromWidgetOfExactType”。
我的课是
part 'APIService.chopper.dart';
@ChopperApi(baseUrl:"/b/")
abstract class ApiService extends ChopperService {
@Get(path: "5e1219328d761771cc8b9394")
Future<Response> getPost();
static ApiService create() {
final client = ChopperClient(
baseUrl: "https://api.jsonbin.io/",
services: [_$ApiService(),],
converter: JsonConverter());
return _$ApiService(client);
}
}
然后我调用这个函数来测试 Chooper
void testAPI() async
{
final response = await Provider.of<ApiService>(context).getPost();
print(response.body);
}
但我遇到了问题,我无法调用 testAPI 你能帮我吗?
提前谢谢你,顺便说一句语法对不起,
【问题讨论】:
标签: android ios flutter mvp chopper