Jaguar-dart/client

Getting below error on upgrading jaguar_retrofit to 2.8.1

Closed this issue ยท 6 comments

E/flutter (12053): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (12053): Exception: Converter for content type 'application/json' not found!
E/flutter (12053): #0 ApiClient.decodeOne (package:jaguar_retrofit/client/client.dart:23:7)
E/flutter (12053):
E/flutter (12053): #1 _RootZone.runUnary (dart:async/zone.dart:1379:54)
E/flutter (12053): #2 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (12053): #3 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
E/flutter (12053): #4 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
E/flutter (12053): #5 Future._complete (dart:async/future_impl.dart:476:7)
E/flutter (12053): #6 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter (12053): #7 _AsyncAwaitCompleter.complete. (dart:async/runtime/libasync_patch.dart:33:20)
E/flutter (12053): #8 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (12053): #9 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

Current implementation of the api-service file is as below:
import "dart:async";

import 'package:jaguar_resty/jaguar_resty.dart' as resty;
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
import 'package:jaguar_serializer/jaguar_serializer.dart';
import 'package:rozana_api_service/data/model/dto/credentials.dart';
import 'package:rozana_api_service/data/model/dto/customer.dart';

part 'auth_api_service.jretro.dart';

@GenApiClient(path: "api")
class AuthApiService extends ApiClient with _$AuthApiServiceClient {
final resty.Route base;

final JsonRepo jsonConverter;

AuthApiService({this.base, this.jsonConverter});

@PostReq(path: "register")
Future registerCustomer(@asjson() Customer Customer);

@PostReq(path: "authenticate")
Future authenticateUser(@asjson() Credentials credentials);
}

@noisytempo Please change the code to:

import "dart:async";

import 'package:jaguar_resty/jaguar_resty.dart' as resty;
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
import 'package:jaguar_serializer/jaguar_serializer.dart';
import 'package:rozana_api_service/data/model/dto/credentials.dart';
import 'package:rozana_api_service/data/model/dto/customer.dart';

part 'auth_api_service.jretro.dart';

@GenApiClient(path: "api")
class AuthApiService extends ApiClient with _$AuthApiServiceClient {
final resty.Route base;

AuthApiService({this.base, CodecRepo jsonConverter}) {
  this.jsonConverter = jsonConverter;
}

@PostReq(path: "register")
Future registerCustomer(@asjson() Customer Customer);

@PostReq(path: "authenticate")
Future authenticateUser(@asjson() Credentials credentials);
}

@tejainece The code you have mentioned above still does not solve the issue. I am still getting the issue mentioned above on the fresh run but on hot reload, the issue seems to go away and final converters = <String, CodecRepo>{}; gets populated on hot reload and not when the code is executed for the first time

After Flutter clean, this issue is now resolved. Thanks ๐Ÿ™‚

Awesome!

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Exception: Converter for content type 'application/pdf' not found!
E/flutter ( 8390): #0 ApiClient.decodeOne (package:jaguar_retrofit/client/client.dart:23:7)
E/flutter ( 8390):
E/flutter ( 8390): #1 _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter ( 8390): #2 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter ( 8390): #3 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
E/flutter ( 8390): #4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
E/flutter ( 8390): #5 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
E/flutter ( 8390): #6 Future._complete (dart:async/future_impl.dart:473:7)
E/flutter ( 8390): #7 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter ( 8390): #8 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:28:18)
E/flutter ( 8390): #9 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:294:13)
E/flutter ( 8390): #10 AsyncStringResponse.run. (package:jaguar_resty/response/response.dart)
E/flutter ( 8390):
E/flutter ( 8390): #11 _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter ( 8390): #12 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter ( 8390): #13 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
E/flutter ( 8390): #14 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
E/flutter ( 8390): #15 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
E/flutter ( 8390): #16 Future._complete (dart:async/future_impl.dart:473:7)
E/flutter ( 8390): #17 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter ( 8390): #18 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:28:18)
E/flutter ( 8390): #19 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:294:13)
E/flutter ( 8390): #20 Get.go. (package:jaguar_resty/routes/routes.dart)
E/flutter ( 8390):
E/flutter ( 8390): #21 _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter ( 8390): #22 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter ( 8390): #23 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
E/flutter ( 8390): #24 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
E/flutter ( 8390): #25 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
E/flutter ( 8390): #26 Future._completeWithValue (dart:async/future_impl.dart:483:5)
E/flutter ( 8390): #27 Future._asyncComplete. (dart:async/future_impl.dart:513:7)
E/flutter ( 8390): #28 _rootRun (dart:async/zone.dart:1124:13)
E/flutter ( 8390): #29 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 8390): #30 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter ( 8390): #31 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter ( 8390): #32 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 8390): #33 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

Doctor summary (to see all details, run flutter doctor -v):
[โˆš] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 10.0.17134.829], locale en-IN)

[โˆš] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[โˆš] Android Studio (version 3.4)
[โˆš] Connected device (1 available)

โ€ข No issues found!