Ch-15: Problem using moor_generator

I am having this error when trying to use moor_genarator:

`/C:/flutter/.pub-cache/hosted/pub.dartlang.org/moor_generator-4.4.1/lib/src/writer/database_writer.dart:4:8: Error: Error when reading '/C:/flutter/.pub-cache/hosted/pub.dartlang.org/moor-4.6.1+1/lib/`
`src/runtime/executor/stream_queries.dart': The system cannot find the path specified.`

I checked:

  • there are three moor files in my flutter .pub-cashe folder, moor-4.6.1+1, moor_flutter-4.0.0, moor_genarator-4.4.1
  • there are no upgraded version after moor-4.0.0
  • flutter pub get was successful
  • In my pubspac.yaml - moor_generator: ^4.4.1, moor_flutter: ^4.0.0
1 Like

You have to override moor:4.4.0 dependency using dependency_override section

dependencies:
  flutter:
    sdk: flutter

  ...
  moor_flutter: ^4.0.0

dependency_overrides:
  moor: '4.4.0'

dev_dependencies:
  flutter_test:
    sdk: flutter

  ...
  moor_generator: ^4.4.1

then run following command in terminal/command prompt get packages

flutter clean
flutter pub get

the run following command to generate moor files.

flutter pub run build_runner build --delete-conflicting-outputs

6 Likes

My generation error was :

[SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart.

This is likely caused by a misconfigured builder definition.

pub finished with exit code 78

Work for me too.
Thanks :+1:

1 Like