Search code examples
flutterdartmobilediobuild-runner

type 'ExpandIterable<InterfaceType, MethodElement>' is not a subtype of type 'Iterable<MethodElementImpl>' of 'iterable'


I want to create a api services using dio and build_runner. But when I run flutter pub run build_runner this command on terminal I got this error

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

type 'ExpandIterable<InterfaceType, MethodElement>' is not a subtype of type 'Iterable' of 'iterable'

This is my api services code.

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);
}

Solution

  • Reported Issue : https://github.com/trevorwang/retrofit.dart/issues/345

    Temp fix:

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

    UPDATE

    As the Jun 4, 2021 we get new package update, that fix the problem.

    retrofit_generator 2.0.0+1