Jaguar-dart/jaguar_serializer

Generic classes

sutbult opened this issue · 0 comments

I have two classes that look like this:

class ApiError {
  final String message;
  ApiError({this.message});
}
class ApiResponse<T> {
  final T data;
  final ApiError error;
  ApiError({this.data, this.error});
}

I would like to create a serializer for ApiResponse. However, I cannot figure out how to use jaguar_serializer to achieve this. Every instance of T would have a serializer.

I have tried to specify a list containing all available serializers through the serializers argument to @GenSerializer, but this does not work as the builder does not understand how to handle T.

I have also tried to set a custom processor to the field data through the fields argument to @GenSerializer, but this does not work either as the type T cannot be found.