flutter - 改造生成器构建失败
问题描述
我已经更新了我的插件并得到了改造错误,所以我删除了 api_service.g.dart 并再次尝试重新生成它,但我无法构建这个文件,请帮助我。
环境:sdk:">=2.7.0 <3.0.0"
依赖项:颤振:sdk:颤振提供者:^5.0.0 改造:^2.0.0 json_annotation:^4.0.0 记录器:^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
连接性: ^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
飞镖文件
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,);
}
我得到的错误
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
请帮忙。提前致谢。
解决方案
改变
环境:sdk:">=2.X.0 <3.0.0"
至
环境:sdk:">=2.12.0 <3.0.0"
推荐阅读
- python - mypyc:实现代理对象
- flutter - is there any way to regenerate flutter framework
- java - Maven 全新安装失败
- grep - 在分隔符上拆分后搜索单词
- python - Poor spectral clustering performance using pre-computed affinities
- nest-device-access - Accessing Kwikset Lock Via Google Hub
- javascript - 如何创建具有所有输入类型选项的动态待办事项列表:文本、复选框、日期框、Javascript 中的单选选项?
- r - 如何根据 R Shiny 中的用户输入更改 ggplot 地图的颜色
- java - 如何将 Okta SSO 与 Java Swing 集成
- flutter - 颤动卡渲染溢出问题