flutterdartflutter-moordrift

Build runner not working as expected in flutter drift


flutter packages pub run build_runner build --delete-conflicting-outputs the build runner works perfectly for dao files and generates .g.dart files except for the file containing database class and tables

my 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

the build runner output

[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)

I've tried flutter clean flutter pub get flutter pub upgrade so I can't generate database files ,what should I do? thanks in advance


Solution

  • ensure using Drift @DriftDatabase() directly over your dataBase class