-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intermittent error: Could not resolve annotation for class $Test
.
#1611
Comments
➤ PM Bot commented: Jira ticket: RDART-994 |
you must rename Model class must start with |
@jankuo and @derrickgw You can name the model @derrickgw Is the above short snippet enough to reproduce the issue for you? What version of As a workaround, can you try to delete the |
@jankuo I was also surprised that @nielsenko I have seen the error even with this small example. I am sure that deleting .dart_tool folder would work. Simply changing the file and running build_runner again will clear the error. I have seen the error with both 1.6 and 2.0. I recognize that it is hard to track down intermittent errors like this. Is there any sort of extra debugging or logging I can turn on to get more information? |
@derrickgw I believe it is an issue with the |
I don't rely directly on analyzer. It looks like I am using 6.2. I can try explicitly referencing it and upgrading to 6.4 to see if that has an impact. |
I upgraded flutter and analyzer to the latest, and was still able to get the error: deleting .dart_tool almost makes it happen reliably on the 2nd build. I wrote a test script and attached the output.
|
@derrickgw Thanks! I'll try to reproduce on my end. |
@derrickgw I managed to hit the issue. Now I "just" need to figure out why. |
This issue also occurs with the latest realm 2.0 / flutter 3.19.5. There is a workaround, in the source file that defines the schema, import import 'package:realm/realm.dart';
+++ import 'package:realm_common/realm_common.dart'; Second build runs well after this change, no more Don't forget |
Maybe dart codegen does not support indirect package import when caching?
Riverpod requires adding |
realm: ^2.3.0 has same issue and this solution worked. |
This solution has worked for me too.
|
What happened?
Every so often, the build generator throws an error on the Annotation. I estimate this happens 1 out of 10 times.
I have also noticed that when it happens the build running tries to execute a few thousand steps instead of a few hundred.
When it is in this state, rerunning it doesn't fix it. I have to modify the file (usually I add an extra newline) for it to run correctly.
Repro steps
Run the buildrunner. Every so often it will crash on the first insatnce of
@RealmObject()
in the file.Version
Dart 3.2.6/Flutter 3.16.9
What type of application is this?
Flutter Application
Client OS and version
Ubuntu 20.04.4 LTS
Code snippets
Stacktrace of the exception/crash you're getting
Relevant log output
The text was updated successfully, but these errors were encountered: