【问题标题】:type 'ExpandIterable<InterfaceType, MethodElement>' is not a subtype of type 'Iterable<MethodElementImpl>' of 'iterable'类型“ExpandIterable<InterfaceType, MethodElement>”不是“iterable”的“Iterable<MethodElementImpl>”类型的子类型
【发布时间】:2021-08-16 19:16:47
【问题描述】:

我想使用 dio 和 build_runner 创建一个 api 服务。但是当我在终端上运行flutter pub run build_runner这个命令时,我得到了这个错误

[严重] retrofit_generator:retrofit on lib/web_services/api_services.dart:

type 'ExpandIterable' 不是子类型 'iterable' 类型的'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);
}

【问题讨论】:

  • 这似乎是包本身的错误,您应该前往 repo 并提出问题

标签: flutter dart mobile dio build-runner


【解决方案1】:

报告的问题: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

【讨论】:

    猜你喜欢
    • 2020-08-11
    • 2021-09-13
    • 2020-06-17
    • 2021-01-17
    • 1970-01-01
    • 2020-11-25
    • 2021-06-19
    • 2019-01-03
    • 2019-03-14
    相关资源
    最近更新 更多