google / google/built_value.dart
Even better message than "make field ... have non-dynamic type"
- Dominant language
- Dart
- Stars
- 886
- Forks
- 195
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 4
Description
Just spent half an hour figuring out how to deal with the following error when using a class from a different part of the project tree in a built value class.
```
[SEVERE] built_value_generator:built_value on lib/src/remote_files/parser/bvtest.dart:
Error in BuiltValueGenerator for abstract class Aard implements Built.
Please make the following changes to use BuiltValue:
1. Make field path have non-dynamic type. If you are already specifying a type, please make sure the type is correctly imported.
```
The solution ended up being to make the `targets.$defaults.sources` in `build.yaml` include not only the places where I want to generate built value classes (and other places where I'm using other generated code tools), but to include classes I want to reference from these. In retrospect, it seems obvious. And yet, I found I had to do a bunch of experimenting to find out this was the case.
An error message pointing out that "type is correctly imported" might mean "check the paths in build.yaml" would have helped a lot.
See also, the previous improvement to this message: https://github.com/google/built_value.dart/issues/256
Contributor guide
Assessment
This issue has not been assessed yet.