I have generated model and provider by:
get generate model from 'https://jsonplaceholder.typicode.com/todos/1'
But when doing any request, it throws exception: Unhandled Exception: type '(dynamic) => Object?' is not a subtype of type '((dynamic) => Todo)?' in type cast
If I change the httpClient.defaultDecoder to:
httpClient.defaultDecoder = (map) { return Todo.fromJson(map); };
works OK. But if I add a method to get the todo list, then does not because as you can see the list decoder is needed but is not provided anymore and throws:
Unhandled Exception: type '(dynamic) => Todo' is not a subtype of type '((dynamic) => List<Todo>)?' in type cast
I have generated model and provider by:
get generate model from 'https://jsonplaceholder.typicode.com/todos/1'
But when doing any request, it throws exception: Unhandled Exception: type '(dynamic) => Object?' is not a subtype of type '((dynamic) => Todo)?' in type cast
The generated provider code:
If I change the
httpClient.defaultDecoder
to:httpClient.defaultDecoder = (map) { return Todo.fromJson(map); };
works OK. But if I add a method to get the todo list, then does not because as you can see the list decoder is needed but is not provided anymore and throws:Unhandled Exception: type '(dynamic) => Todo' is not a subtype of type '((dynamic) => List<Todo>)?' in type cast