Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response type of list of models with generic field -> Generates code with error #681

Open
moshe5745 opened this issue Jun 9, 2024 · 0 comments

Comments

@moshe5745
Copy link
Contributor

To Reproduce

import 'package:json_annotation/json_annotation.dart';

part 'api_response.g.dart';

@JsonSerializable(genericArgumentFactories: true)
class SomeModelWithGenericType<T> {
  final T data;

  SomeModelWithGenericType(
      {required this.data,
    });

  factory SomeModelWithGenericType.fromJson(Map<String, dynamic> json, T Function(Object? json) fromJsonT) => _$SomeModelWithGenericTypeFromJson(json, fromJsonT);

  Map<String, dynamic> toJson(Object? Function(T) toJsonT) => _$SomeModelWithGenericTypeToJson(this, toJsonT);
}

class SomeModel {
   final String name;
}

  @GET('/some/api')
  Future<List<SomeModelWithGenericType<SomeModel>>> getSomething();

Expected behavior
To generate code without errors

Screenshots
image

Flutter 3.22.0 • channel stable

dependencies:
  json_annotation: ^4.9.0

dev_dependencies:
  json_serializable: ^6.8.0
  retrofit_generator: ^8.1.0
  build_runner: '>=2.4.10 <4.0.0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant