drift
drift copied to clipboard
Error: Method not found: 'BaseReferences'.
I am using drift: ^2.19.1+1 and drift_dev: ^2.19.1 version i get below given error
Error: Method not found: 'BaseReferences'.
Future<void> validateDatabaseSchema(GeneratedDatabase database) async {
^^^^^^^^^^^^^^^^^
Error: Compilation failed.
Command: D:\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev D:\flutter\bin\cache\dart-sdk\bin\snapshots\dart2js.dart.snapshot --platform-binaries=D:\flutter\bin\cache\flutter_web_sdk\kernel --invoker=flutter_tool
-Ddart.vm.product=true -DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/55eae6864b296dd9f43b2cc7577ec256e5c32a8d/ -DFLUTTER_WEB_AUTO_DETECT=false -DFLUTTER_WEB_USE_SKIA=false --native-null-assertions
--no-source-maps -o E:\elaunch projects\leylix-flutter\.dart_tool\flutter_build\a913532f8543273f5c68b3d2a8e67ace\app.dill --packages=.dart_tool/package_config.json --cfe-only E:\elaunch
projects\leylix-flutter\.dart_tool\flutter_build\a913532f8543273f5c68b3d2a8e67ace\main.dart
This appears to be similar to https://github.com/simolus3/drift/issues/3168 and https://github.com/simolus3/drift/issues/3163.
Basically, it looks like your code has been generated by drift_dev version 2.20.0 but is running against drift version 2.19.x. I don't exactly understand how that's possible since drift_dev has a dependency on the same minor drift version, but I think you can fix it by either:
- Making sure you're not on
drift_devversion2.20.xand re-runningbuild_runner buildto generate code compatible withdriftversion2.19.x. - Upgrading
driftto2.20.0and keeping the generated code unchanged.
This is possible if database code is in the local package.
My main app resolves its drift_dev version to 2.19.1 until I forcefully run pub get despite my package using 2.20.1. In my case it couldn't update drift_dev version automatically as some other package depends on web <0.6.0.
App:
Package:
This is because of conflicting versions of drift. I had to get into pub-cache (~/.pub-cache/hosted/pub.dev/) and manually delete the older versions of drift.