title: Retrofit Dart exception on processing JSON
body: <p>New to Dart/Flutter.</p>
  
  <p>Trying to use the retrofit dart package, but my test code ends with exception:</p>
  
  <pre><code>DioError [DioErrorType.DEFAULT]: type 'String' is not a subtype of type 'Map&lt;String, dynamic&gt;'
  </code></pre>
  
  <p>My pubspec.yaml (snippet):</p>
  
  <pre><code>dependencies:
  
    json_serializable: ^3.2.2
    json_annotation: 3.0.0
    retrofit: any
    logger: 0.7.0  #for logging purpose
  
    flutter:
      sdk: flutter
  
    # The following adds the Cupertino Icons font to your application.
    # Use with the CupertinoIcons class for iOS style icons.
    cupertino_icons: ^0.1.2
  
  dev_dependencies:
  
    retrofit_generator: any
    build_runner: any
  
    flutter_test:
      sdk: flutter
    ...
  </code></pre>
  
  <p>My API and classes:</p>
  
  <pre><code>import 'package:json_annotation/json_annotation.dart';
  import 'package:retrofit/retrofit.dart';
  import 'package:dio/dio.dart';       
  part 'regions.g.dart';
  
  @RestApi(baseUrl: "https://soargbsc.com/rasp/")
  abstract class RaspClient {
    factory RaspClient(Dio dio) = _RaspClient;
  
    @GET("current.json")
    Future&lt;Regions&gt; getRegions();
  }
  
  List&lt;Regions&gt; to List&lt;Region&gt;, etc
  
  @JsonSerializable()
  class Regions {
    String initialRegion;
    List&lt;Region&gt; regions;
    Airspace airspace;
  
    Regions({this.initialRegion, this.regions, this.airspace});
    factory Regions.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$RegionsFromJson(json);
    Map&lt;String, dynamic&gt; toJson() =&gt; _$RegionsToJson(this);
   }
  
  @JsonSerializable()
  class Region {
    List&lt;String&gt; dates;
    String name;
    List&lt;String&gt; printDates;
    List&lt;Soundings&gt; soundings;
  
    Region({this.dates, this.name , this.printDates, this.soundings
    });
    factory Region.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$RegionFromJson(json);
    Map&lt;String, dynamic&gt; toJson() =&gt; _$RegionToJson(this);
  }
  
  @JsonSerializable()
  class Soundings {
    String location;
    String longitude;
    String latitude;
  
    Soundings({this.location, this.longitude, this.latitude});
    factory Soundings.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$SoundingsFromJson(json);
    Map&lt;String, dynamic&gt; toJson() =&gt; _$SoundingsToJson(this);
  }
  
  @JsonSerializable()
  class Airspace {
    String baseUrl;
    List&lt;String&gt; files;
  
     Airspace({this.baseUrl, this.files});
    factory Airspace.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$AirspaceFromJson(json);
    Map&lt;String, dynamic&gt; toJson() =&gt; _$AirspaceToJson(this);
  }
  </code></pre>
  
  <p>I ran the flutter packages pub run build_runner watch  command and confirmed the appropriate code was gen'ed into regions.g.dart.</p>
  
  <p>When I run my test program below I do see the Json displayed via LogInterceptor but then get the exception.</p>
  
  <pre><code>void main() {
    test("Get current.json", () async {
      final dio = Dio();
      dio.interceptors.add(LogInterceptor(responseBody: true));
      final client = RaspClient(dio);   
      client.getRegions().then(expectAsync1(
              (regions) =&gt; print("Regions: ${regions.regions.length}")
              ))
          ;
    });
  }
  </code></pre>
  
  <p>The exception is being thrown in dio.dart</p>
  
  <pre><code> Response&lt;T&gt; assureResponse&lt;T&gt;(response, [RequestOptions requestOptions]) {
      if (response is Response&lt;T&gt;) {
        response.request = response.request ?? requestOptions;
      } else if (response is! Response) {
        response = Response&lt;T&gt;(data: response, request: requestOptions);
      } else {
        T data = response.data; &lt;&lt;&lt;&lt; Exception happens here &lt;&lt;&lt;&lt;&lt;&lt;&lt;
        response = Response&lt;T&gt;(
          data: data,
          headers: response.headers,
          request: response.request,
          statusCode: response.statusCode,
          isRedirect: response.isRedirect,
          redirects: response.redirects,
          statusMessage: response.statusMessage,
        );
      }
      return response;
    }
  </code></pre>
  
  <p>Any ideas what is going wrong here? Do I also need to define a converter somewhere? </p>