Fork from retrofit_generator, adapt to generic_json_serializable, Automatically generate api calling code, which has custom generic class.

abstract class UserClient {
  factory UserClient(Dio dio) = _UserClient;

  Future<ApiResult<String, User>> login(@Body() Map<String, dynamic> data);

  Future<ApiResults<User>> getUsers(@Queries() ApiResult<String, User> data);

Fix use fromJson to decoder a type has geneic parameters.

class _UserClient implements UserClient {
  _UserClient(this._dio, {this.baseUrl}) {
    ArgumentError.checkNotNull(_dio, '_dio');

  final Dio _dio;

  String baseUrl;

  login(data) async {
    ArgumentError.checkNotNull(data, 'data');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    _data.addAll(data ?? <String, dynamic>{});
    final Response<Map<String, dynamic>> _result = await _dio.request(
        queryParameters: queryParameters,
        options: RequestOptions(
            method: 'POST',
            headers: <String, dynamic>{},
            extra: _extra,
            baseUrl: baseUrl),
        data: _data);
    final value = ApiResult<String, User>.fromJson(,
        fromJson1: (v) => v as String, fromJson2: (v) => User.fromJson(v));
    return value;