Build runner 在 flutter drift 中没有按预期工作

Build runner not working as expected in flutter drift

flutter packages pub run build_runner build --delete-conflicting-outputs 构建运行器非常适合 dao 文件并生成 .g.dart 文件,但包含数据库 class 和表

的文件除外

我的pupspec.yaml

dependencies:
  flutter:
    sdk: flutter
  drift: ^1.6.0
  drift_sqflite: ^1.0.0
  path_provider: ^2.0.0
  path: ^1.8.1
  json_serializable: ^6.2.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.1
  drift_dev: ^1.6.0
  build_runner: ^2.1.10

构建运行程序输出

[INFO] Generating build script...
[INFO] Generating build script completed, took 292ms

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

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

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Deleting 43 declared outputs which already existed on disk.
[INFO] Checking for unexpected pre-existing outputs. completed, took 5ms

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

[INFO] 3.4s elapsed, 4/20 actions completed.
[INFO] 4.4s elapsed, 4/20 actions completed.
[INFO] 5.5s elapsed, 4/20 actions completed.
[INFO] 6.5s elapsed, 4/20 actions completed.
[INFO] 8.7s elapsed, 4/20 actions completed.
[INFO] 11.3s elapsed, 4/20 actions completed.
[INFO] 13.4s elapsed, 4/20 actions completed.
[INFO] 14.4s elapsed, 31/47 actions completed.
[INFO] 15.4s elapsed, 31/47 actions completed.
[INFO] 16.5s elapsed, 36/52 actions completed.
[INFO] 17.6s elapsed, 63/79 actions completed.
[INFO] 18.6s elapsed, 119/133 actions completed.
[INFO] 19.7s elapsed, 195/211 actions completed.
[INFO] 20.7s elapsed, 258/261 actions completed.
[INFO] Running build completed, took 20.7s

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

[INFO] Succeeded after 20.8s with 86 outputs (304 actions)

我试过了flutter cleanflutter pub getflutter pub upgrade 所以我无法生成数据库文件,我该怎么办? 提前致谢

确保直接在您的数据库上使用 Drift @DriftDatabase() class