chopper icon indicating copy to clipboard operation
chopper copied to clipboard

Type cast error when using FactoryConverter

Open TheLastFlame opened this issue 6 months ago • 2 comments

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 avatar Aug 27 '24 07:08 TheLastFlame