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

Generic classes #190

Open
sutbult opened this issue Mar 10, 2020 · 0 comments
Open

Generic classes #190

sutbult opened this issue Mar 10, 2020 · 0 comments

Comments

@sutbult
Copy link

sutbult commented Mar 10, 2020

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.

@sutbult sutbult changed the title Generic models Generic classes Mar 10, 2020
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