我想使用 dio 和 build_runner 创建一个 api 服务。但是当我运行 flutter pub run build_runner
终端上的这个命令我收到了这个错误
[SEVERE] retrofit_generator:retrofit on lib/web_services/api_services.dart:
type 'ExpandIterable<InterfaceType, MethodElement>' is not a subtype of type 'Iterable' of 'iterable'
这是我的 api 服务代码。
part 'api_services.g.dart';
@RestApi(baseUrl: Preferences.hrmsAPI)
abstract class RestClient {
factory RestClient(Dio dio) = _RestClient;
@FormUrlEncoded()
@GET('config')
Future<WrappedResponse> config();
@FormUrlEncoded()
@GET('profile')
Future<WrappedResponse> profile(@Header('Authorization') String token);
}
最佳答案
报告的问题:https://github.com/trevorwang/retrofit.dart/issues/345
临时修复:
retrofit_generator:
git:
url: https://github.com/Chimerapps/retrofit.dart.git
ref: 9f90296751984b359937c38563da5b19db5550f5
path: generator
更新 随着 2021 年 6 月 4 日,我们获得了新的软件包更新,从而解决了问题。
retrofit_generator 2.0.0+1
关于flutter - 类型 'ExpandIterable<InterfaceType, MethodElement>' 不是类型 'Iterable<MethodElementImpl>' 的 'iterable' 的子类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67740588/