VB10 / vexana

Vexana is network manager project with dio.
https://pub.dev/packages/vexana
MIT License
147 stars 42 forks source link

Parsing of EmptyParseModel throws error if response.body contains List #76

Closed behzodfaiziev closed 1 year ago

behzodfaiziev commented 1 year ago
 final response = await manager.send<EmptyModel, EmptyModel>(
        APIConst.example,
        parseModel: EmptyModel(),
        method: RequestType.POST,
        data: example.toJson(),
      );

Partially Working Case

Response type: Map<String,dynamic>

Expected result:

response.data = EmptyModel(name: "anydata");

Actual result:

response.data = EmptyModel(name: null); // it doesn't give name, but at least data is not null

Not Working Case

Response type: List<Map<String,dynamic>>

Expected result:

response.data = EmptyModel(name: "anydata");

Actual result:

response.data = null;

It throws an error: Parse Error: type 'List<EmptyModel>' is not a subtype of type 'EmptyModel' in type cast - response body: [{example: 1}] T model: EmptyParseModel , R model: EmptyParseModel

What is next:

I found a solution but I need to make sure that it works. After a while I am going to create PR if I succesfully test it

behzodfaiziev commented 1 year ago

@VB10 I've fixed this issue. Since I have already opened PR before, changes were sent to #75. If the solution is not good, feel free to request changes

MehmetKaranlik commented 1 year ago

@VB10 @behzodfaiziev Since its merge im closing this issue.