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

Type cast error when using FactoryConverter #631

Open
TheLastFlame opened this issue Aug 27, 2024 · 2 comments
Open

Type cast error when using FactoryConverter #631

TheLastFlame opened this issue Aug 27, 2024 · 2 comments
Labels
investigation The issue needs further investigation question Further information is requested

Comments

@TheLastFlame
Copy link

Steps to Reproduce

Use FactoryConverter for a request with the specified response type.

Expected results:
Correct behavior similar to global converter usage

Actual results:
type 'List' is not a subtype of type 'Response<List<Map<String, dynamic>>>' in type cast

Code sample
@ChopperApi()
abstract class API extends ChopperService {
  static API create() {
    final client = ChopperClient(
      baseUrl: Uri.parse(url),
      converter: const JsonConverter(),
      errorConverter: const JsonConverter(),
    );
    return _$AuthorTodayAPI(client);
  }
  @FactoryConverter(response: convertResponse)
  @Get(path: path)
  Future<Response<List<Map<String, dynamic>>>> fetch();
}

FutureOr<Response<T>> convertResponse<T>(Response res) =>
    const JsonConverter().convertResponse(res);
Logs
type 'List<dynamic>' is not a subtype of type 'Response<List<Map<String, dynamic>>>' in type cast
No issues found!
Dart SDK version: 3.5.0 (stable) (Tue Jul 30 02:17:59 2024 -0700) on "windows_x64"
@TheLastFlame TheLastFlame added the bug Something isn't working label Aug 27, 2024
@techouse techouse added question Further information is requested and removed bug Something isn't working labels Sep 5, 2024
@techouse
Copy link
Collaborator

techouse commented Sep 5, 2024

Hi, can you please provide an example / repo which reproduces this error?

@techouse techouse self-assigned this Sep 5, 2024
@techouse techouse added investigation The issue needs further investigation bug Something isn't working labels Sep 5, 2024
@TheLastFlame
Copy link
Author

TheLastFlame commented Sep 7, 2024

Hi, can you please provide an example / repo which reproduces this error?

Is it possibly related to #173?

Hi. Unfortunately, I've already over-worked that code and I don't have any copies left.
I created a new project to demonstrate it, but I got a different behaviour.
Now I get this error even without FactoryConverter.

I'll try to investigate this further when I have more free time.

@techouse techouse removed the bug Something isn't working label Sep 9, 2024
@techouse techouse removed their assignment Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation The issue needs further investigation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants