[英]Chopper using MVP Architecture in flutter
Im using Chopper for calling api and i want to get result json, this is the API i want to call [ https://api.jsonbin.io/b/5e1219328d761771cc8b9394]我使用 Chopper 调用 api,我想得到结果 json,这是我想调用的 API [ https://api.jsonbin.io/b/5e1219328d761771cc8b9394]
I would like to ask how to resolve this kind of problem,请问这种问题怎么解决
Unhandled Exception: NoSuchMethodError: The method 'inheritFromWidgetOfExactType' was called on null.未处理的异常:NoSuchMethodError:在 null 上调用了方法“inheritFromWidgetOfExactType”。
my class is我的课是
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);
}
}
and then I'm calling this function to test the Chooper然后我调用这个函数来测试 Chooper
void testAPI() async
{
final response = await Provider.of<ApiService>(context).getPost();
print(response.body);
}
But i having a problem and i cannot call testAPI can you help me ?但是我有一个问题,我无法调用 testAPI 你能帮我吗?
Thank you in advance, sorry for the grammar BTW,预先感谢您,对不起语法BTW,
void testAPI() async
{
final response = await ApiService.create().getPost();
print(response.body);
}
This is correct answer for my questions这是我问题的正确答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.