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

Converter types fix #34

Merged
merged 4 commits into from
Mar 16, 2019
Merged

Converter types fix #34

merged 4 commits into from
Mar 16, 2019

Conversation

MichaelDark
Copy link

@MichaelDark MichaelDark commented Mar 15, 2019

I have just faced the issue, that if you want to convert Response from JSON string to a List of objects, you can not do it because converter does not know about the Body type, and request fails on converting.

Future<Response<Body>> _decodeResponse<Body, ToDecode>(...) async {
    ...
    final converted = await withConverter.convertResponse<ToDecode>(response);
    ...
    return converted;
  }

image

Unhandled Exception: type 'Response<dynamic>' is not a subtype of type 'FutureOr<Response<List<Language>>>'

You can play with this types, but in this case without extra generic type you cannot get working program

The main idea of solution - just to add ResultType to converters with renaming ToDecode to ItemType

In Converter:
convertResponse<ToDecode> => convertResponse<ResultType, ItemType>

@lejard-h If you can, polish this variant (if needed) and give a stable version 2.2.0 (fox example) as fast as possible :)

@lejard-h
Copy link
Owner

Thanks, can you fix CI ?
regenerate example, test and format the code

@MichaelDark
Copy link
Author

MichaelDark commented Mar 16, 2019 via email

@MichaelDark
Copy link
Author

MichaelDark commented Mar 16, 2019

@lejard-h Looking forward for merge and publishing new version

@lejard-h
Copy link
Owner

Looks good thanks :)

@lejard-h lejard-h merged commit 9033876 into lejard-h:master Mar 16, 2019
@MichaelDark
Copy link
Author

@lejard-h Could you publish new version to dartpub? I realy need this fix (new version v2.1.1) :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants