Kar*_*ani 5 serialization json flutter build-runner
我在使用 build_runner 获取 json 文件所需的输出时遇到问题,它运行成功,但没有给出任何输出
我的第一个.dart 文件
```
import 'package:json_annotation/json_annotation.dart';
part 'first.g.dart';
@JsonSerializable()
class User {
String visibility, name;
User(this.visibility, this.name);
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
Map<String, dynamic> toJson() => _$UserToJson(this);
}
```
Run Code Online (Sandbox Code Playgroud)
我的项目中是否需要任何 buil.yaml 文件?
我的 pubspec.yaml 文件
```
dependencies:
flutter:
sdk: flutter
json_annotation: ^4.4.0
http: ^0.13.4
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.1.7
json_serializable: ^6.1.1
```
Run Code Online (Sandbox Code Playgroud)
这是执行命令后我的终端的样子
flutter pub run build_runner build
Run Code Online (Sandbox Code Playgroud)
终端
PS D:\Flutter\json_parse\learn> flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 359ms
[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 7.0s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 758ms
[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.5s elapsed, 0/3 actions completed.
[INFO] Generating SDK summary completed, took 3.5s
[INFO] 4.6s elapsed, 0/3 actions completed.
[INFO] 5.6s elapsed, 0/3 actions completed.
[INFO] 7.0s elapsed, 0/3 actions completed.
[INFO] 12.9s elapsed, 1/3 actions completed.
[INFO] Running build completed, took 13.6s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 30ms
[INFO] Succeeded after 13.6s with 0 outputs (6 actions)
Run Code Online (Sandbox Code Playgroud)
我不明白我的代码有什么问题
小智 0
将其添加到 pubspec.ymal 文件中
dependencies:
flutter:
sdk: flutter
hive: ^2.2.1
path_provider: ^2.0.10
json_annotation: ^3.0.0
hive_flutter: ^1.0.0
hive_generator: ^1.0.0
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.3.1
json_serializable: ^3.2.2
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2046 次 |
| 最近记录: |