retrofit_generator:在Flutter上升级到Null Safe版本后发生改装故障



我正试图将Flutter应用程序升级为Null Safe,但我遇到了retrofit代码生成器的问题。

所以我有一个RestAPI抽象类,声明如下:


@RestApi(baseUrl: ApiConsts.authBaseURL)
abstract class IAuthApi {
factory IAuthApi(Dio dio) = _IAuthApi;
@POST(ApiConsts.verifyPath)
Future<AccessToken> verifyToken(@Body() VerifyBody body);
}

数据类别如下:

@JsonSerializable(includeIfNull: false)
class VerifyBody {
@JsonKey(name: 'grant_type')
String grantType;
@JsonKey(name: 'client_id')
String clientId;
String username;
String otp;
String realm;
String audience;
String scope;
VerifyBody(this.username, this.otp,
{this.grantType = ApiConsts.GRANT_TYPE,
this.clientId = ApiConsts.CLIENT_ID,
this.realm = ApiConsts.SMS,
this.audience = ApiConsts.AUDIENCE,
this.scope = ApiConsts.AUTH_SCOPE});
factory VerifyBody.fromJson(Map<String, dynamic> json) => _$VerifyBodyFromJson(json);
Map<String, dynamic> toJson() => _$VerifyBodyToJson(this);
}
@JsonSerializable(includeIfNull: false)
class AccessToken {
@JsonKey(name: 'access_token')
String accessToken;
@JsonKey(name: 'refresh_token')
String refreshToken;
@JsonKey(name: 'id_token')
String idToken;
String scope;
@JsonKey(name: 'expires_in')
int expiresIn;
@JsonKey(name: 'token_type')
String tokenType;
AccessToken(this.accessToken, this.refreshToken, this.idToken, this.scope, this.expiresIn,
this.tokenType);
factory AccessToken.fromJson(Map<String, dynamic> json) => _$AccessTokenFromJson(json);
Map<String, dynamic> toJson() => _$AccessTokenToJson(this);
}

当我运行生成改装代码pub run build_runner build --delete-conflicting-outputs的命令时

我得到以下错误:

[SEVERE] retrofit_generator:retrofit on lib/services/api/AuthAPI.dart:
type 'ExpandIterable<InterfaceType, MethodElement>' is not a subtype of type 'Iterable<MethodElementImpl>' of 'iterable'

有人遇到过这样的事情吗?

这是此处报告的问题。

它将在下一个版本中修复。

对于临时修复:

retrofit_generator:
git:
url: https://github.com/Chimerapps/retrofit.dart.git
ref: 9f90296751984b359937c38563da5b19db5550f5
path: generator

最新更新