2

I'm using retrofit in my flutter application and I'm using json_serialzable as well to generate model classes. here is my pubspec:

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  get: ^3.24.0
  flutter_custom_clippers: ^1.1.2
  font_awesome_flutter: ^8.11.0
  firebase_core: ^0.7.0
  firebase_auth: ^0.20.1
  cloud_firestore: ^0.16.0+1
  google_sign_in: ^4.5.9
  chips_choice: ^2.0.1
  logging: ^0.11.4
  path_provider: ^1.6.27
  hive: ^1.4.4+1
  hive_flutter: ^0.3.1
  retrofit: ^1.3.4+1
  dio: ^3.0.10
  json_annotation: ^3.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  hive_generator: ^0.8.2
  retrofit_generator: ^1.3.7+5
  build_runner: ^1.10.0
  json_serializable: ^3.5.0

and when I run flutter pub run build_runner build --> it successfully generates the part file for both retrofit service and model that contains fromJson and toJson, but with an error in the service class that Response doesn't have the method fromJson (response not the model class (e.g. user model in the following picture):

enter image description here

I tried changing the versions in pubspec to any but same result when I build. Any help is much appreciated as I'm stuck on this and I prefer to use retrofit with dio over chopper.

M.R.M
  • 540
  • 1
  • 13
  • 30

0 Answers0