flutterretrofitdiojson-serializable

How to generate .g.dart files correctly when added POST/GET method?


Based on the two images here that I screenshot, I'm confused about making RestClient in Retrofit. When I deleted the Post Method, the part file (api_service.g.dart) didn't get an error. Look at this image : enter image description here

But when I add Post Method, the part file (api_service.g.dart) will be error. Looks like this: enter image description here

The error is:

error: Target of URI hasn't been generated: 'api_service.g.dart'. (uri_has_not_been_generated at [apps] lib\data\remote\api_service.dart:6)

and

error: The name '_RestClient' isn't a type and can't be used in a redirected constructor. (redirect_to_non_class at [apps] lib\data\remote\api_service.dart:11)

So, how is the solution? Thanks in advance


Solution

  • Finally it solved by upgrading all version like retrofit, retrofit_generator and build_runner. Thanks everyone