skip to Main Content

I have a chucker error after successfully make an api call. Previously it was okay. But suddenly there is a json encoding issue in chucker library.

I/flutter (18923): Failed to parse JSON: FormatException: Unexpected character (at character 2)
I/flutter (18923): {content-type: application/json, cookie: null, content-length: 876}
I/flutter (18923):  ^
I/flutter (18923): 
I/flutter (18923): Failed to parse JSON: FormatException: Unexpected character (at character 2)
I/flutter (18923): {content-type: application/json, Authorization: Bearer f8896cc1adaf864a88d7...
I/flutter (18923):  ^
I/flutter (18923): 
E/flutter (18923): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Converting object to an encodable object failed: Instance of 'ApiResponse'
E/flutter (18923): #0      _JsonStringifier.writeObject (dart:convert/json.dart:793:7)
E/flutter (18923): #1      _JsonStringifier.writeList (dart:convert/json.dart:844:9)
E/flutter (18923): #2      _JsonStringifier.writeJsonValue (dart:convert/json.dart:823:7)
E/flutter (18923): #3      _JsonStringifier.writeObject (dart:convert/json.dart:784:9)
E/flutter (18923): #4      _JsonStringStringifier.printOn (dart:convert/json.dart:982:17)
E/flutter (18923): #5      _JsonStringStringifier.stringify (dart:convert/json.dart:967:5)
E/flutter (18923): #6      JsonEncoder.convert (dart:convert/json.dart:345:30)
E/flutter (18923): #7      JsonCodec.encode (dart:convert/json.dart:231:45)
E/flutter (18923): #8      jsonEncode (dart:convert/json.dart:114:10)
E/flutter (18923): #9      SharedPreferencesManager.addApiResponse (package:chucker_flutter/src/helpers/shared_preferences_manager.dart:45:7)
E/flutter (18923): <asynchronous suspension>
E/flutter (18923): #10     ChuckerDioInterceptor._saveResponse (package:chucker_flutter/src/interceptors/dio_interceptor.dart:79:5)
E/flutter (18923): <asynchronous suspension>
E/flutter (18923): #11     ChuckerDioInterceptor.onResponse (package:chucker_flutter/src/interceptors/dio_interceptor.dart:45:5)
E/flutter (18923): <asynchronous suspension>

pub.dev:

chucker_flutter: ^1.8.0
dio: ^5.7.0
dio_cookie_manager: ^3.1.1
cookie_jar: ^4.0.8
shared_preferences: ^2.3.2

I have already added this in dio_manager.dart:

Dio().interceptors.add(ChuckerDioInterceptor());

and this in app.dart:

navigatorObservers: [ChuckerFlutter.navigatorObserver],

I have tried to disabled chucker library and everything works normally. But I want chucker library to debug.

2

Answers


  1. Add a header as
    "Content-type": "application/json"

    Login or Signup to reply.
  2. This is fixed in chucker_flutter: ^1.8.1

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search