添加POST/GET方法后如何正确生成.g.dart文件?

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

根据我截取的两张图片,我对在 Retrofit 中制作 RestClient 感到困惑。当我删除 Post 方法时,零件文件 (api_service.g.dart) 没有出现错误。看这张图片:

但是当我添加Post方法时,零件文件(api_service.g.dart)会出错。看起来像这样:

错误是:

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)

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)

那么,怎么解决的呢?提前致谢

检查 build_runner 日志。如果文件未生成,则您的代码中可能存在错误,导致生成器无法成功 运行。

最后通过升级所有版本解决,如改造,retrofit_generator和build_runner。谢谢大家