Retrofit generator build failed

Viewed 1196

I've updated my plugins and got the retrofit errors so I've deleted api_service.g.dart and try again to regenerate that but I'm not able to build this file please help me on this.

environment: sdk: ">=2.7.0 <3.0.0"

dependencies: flutter: sdk: flutter provider: ^5.0.0 retrofit: ^2.0.0 json_annotation: ^4.0.0 logger: ^1.0.0-nullsafety.0
pretty_dio_logger: ^1.1.1 dio: ^4.0.0 razorpay_flutter: ^1.2.6
built_value: ^8.0.6 cupertino_icons: ^1.0.2 flutter_svg: ^0.22.0 simple_animations: ^3.1.1 shared_preferences: ^2.0.6 http: ^0.13.3
flutter_staggered_grid_view: ^0.4.0-nullsafety.3 #fluttertoast: ^4.0.0 reorderables: ^0.4.1 bubble_bottom_bar: ^1.2.0
connectivity: ^3.0.4 webview_flutter: ^2.0.2 charts_flutter: ^0.10.0 fcharts: ^0.0.11 share: ^2.0.0 package_info: ^2.0.2
launch_review: ^3.0.1 loading_animations: ^2.1.0 get: ^4.0.0-nullsafety.2 percent_indicator: ^3.3.0-nullsafety.1
url_launcher: ^6.0.6 firebase_core: ^1.3.0 firebase_crashlytics: ^2.0.6 new_version:

dev_dependencies: flutter_test: sdk: flutter retrofit_generator: ^2.0.0+1 json_serializable: ^4.0.2 build_runner: ^2.0.4 built_value_generator: ^8.0.6

Dart file

   part 'api_service.g.dart';

@RestApi(baseUrl: "https://example.com/")
abstract class ApiService {
  factory ApiService(Dio dio, {String baseUrl}) = _ApiService;

  static ApiService create() {
    final dio = Dio();
    dio.interceptors.add(PrettyDioLogger());
    dio.interceptors.clear();
    return ApiService(dio);
  }

  @POST("project/{id}")
  Future<String> addProject(@Path() String id,
      @Body() Map<String, dynamic> body,);
}

Error I get

chetanmahajan@chetans-mini things_linker % flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 540ms

[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 5.0s

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 495ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms

[INFO] Running build...
[INFO] Generating SDK summary...
[INFO] 3.1s elapsed, 0/16 actions completed.
[INFO] Generating SDK summary completed, took 3.0s

[INFO] 4.1s elapsed, 0/16 actions completed.
[INFO] 5.2s elapsed, 0/16 actions completed.
[INFO] 6.3s elapsed, 0/16 actions completed.
[INFO] 7.3s elapsed, 0/16 actions completed.
[INFO] 8.4s elapsed, 1/17 actions completed.
[INFO] 15.1s elapsed, 3/19 actions completed.
[INFO] 16.1s elapsed, 3/19 actions completed.
[INFO] 17.1s elapsed, 3/19 actions completed.
[INFO] 19.0s elapsed, 3/19 actions completed.
[INFO] 20.0s elapsed, 33/49 actions completed.
[SEVERE] retrofit_generator:retrofit on lib/api_service/api_service.dart:

Could not format because the source could not be parsed:

line 59, column 26 of .: A function body must be provided.
   ╷
59 │ @override Future<String*>* addDevice(id, body) async  { const _extra = <String, dynamic>{};
   │                          ^
   ╵
line 59, column 28 of .: A function body must be provided.
   ╷
59 │ @override Future<String*>* addDevice(id, body) async  { const _extra = <String, dynamic>{};
   │                            ^^^^^^^^^
   ╵
line 98, column 18 of .: Expected to find '>'.
   ╷
98 │ @override Future<String*>* sensorDay(id) async  { const _extra = <String, dynamic>{};
   │                  ^^^^^^
   ╵
line 40, column 26 of .: Operator declarations must be preceded by the keyword 'operator'.
   ╷
40 │ @override Future<String*>* getProjects(id) async  { const _extra = <String, dynamic>{};
   │                          ^
   ╵
line 86, column 11 of .: Methods must have an explicit list of parameters.
   ╷
86 │ @override Future<String*>* sensorHour(id) async  { const _extra = <String, dynamic>{};
   │           ^^^^^^
   ╵
line 92, column 26 of .: Methods must have an explicit list of parameters.
   ╷
92 │ @override Future<String*>* sensorThreeHours(id) async  { const _extra = <String, dynamic>{};
   │                          ^
   ╵
line 46, column 28 of .: A function body must be provided.
   ╷
46 │ @override Future<String*>* updateDevice(id, body) async  { const _extra = <String, dynamic>{};
   │                            ^^^^^^^^^^^^
   ╵
line 53, column 26 of .: A function body must be provided.
   ╷
53 │ @override Future<String*>* deleteDevice(id) async  { const _extra = <String, dynamic>{};
   │                          ^
   ╵
line 53, column 28 of .: A function body must be provided.
   ╷
53 │ @override Future<String*>* deleteDevice(id) async  { const _extra = <String, dynamic>{};
   │                            ^^^^^^^^^^^^
   ╵
line 46, column 26 of .: A function body must be provided.
   ╷
46 │ @override Future<String*>* updateDevice(id, body) async  { const _extra = <String, dynamic>{};
   │                          ^
   ╵
(128 more errors...)
[INFO] Running build completed, took 21.4s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 84ms

[SEVERE] Failed after 21.5s
pub finished with exit code 1

Please help. Thanks in advance.

1 Answers

change

environment: sdk: ">=2.X.0 <3.0.0"

to

environment: sdk: ">=2.12.0 <3.0.0"

Related