Closed AirborneEagle closed 4 years ago
Do you mean packages on pub? i.e., are you using pub to upload/download the packages?
Then, it's expected that you publish the .g.dart
files. See for example built_value_generator
which has the generated files checked in.
Or, maybe you have some other setup?
right! sorry for the confusion. they are local dart packages. so the app pubspec.yaml dependency looks like:
data_models:
path: ../../packages/data_models
Hmm. Then I think that should work as long as the .g.dart files are generated under 'packages/data_models'. Is that not the case?
the device.g.dart
file is right there along side the device.dart
file. :/
I need to be more clear here.
I actually ran into the problem while using the Device
class in a package with my services, and not the Flutter app itself.
models package -> service package -> Flutter app.
device.dart
and device.g.dart
are in the models package.
I was attempting to use the .rebuild()
method in the service package. and it was here where I ran into the problem.
all code is in a mono repo. and the pubspecs all are using the path dependencies.
Does that clarification change anything? maybe?
As far as I know that should just work.
What does dartanalyzer say when you run it on srcs in the service package? It should be able to detect whether the rebuild
method is available, and if not, maybe give some indication as to why not.
FYI, I'll be on vacation for a week, so my next response may take a while.
it simply said method not defined for class Device
but i just removed built_value from the services pubspec, and the error is not longer appearing.
I will leave the dependency off, and I will run flutter clean, and rebuild everything a couple times while you are away, to see if I can re-produce it.
it is possible that the .g.dart file was not yet part of the package when services ran pub get?
I will play around with things this week, and we can touch base when you get back.
wow, I totally forgot about this ticket. Sorry. Things are behaving properly. no issues here. I had similar problems with other libraries, and have narrowed it down to a cache and build problem in my IDE. 👍
:) no worries. Thanks for the update!
I have my model classes in their own package, so that I can easily share them with the multiple apps I am building. When working in the app, I was able to use the built class, and all the custom methods I had written inside the class itself, However, When I went to use the .rebuild() method, it was not defined. Nor were any of the other generated methods.
I found that I needed to add
built_value: ^7.0.8
to the pubspec of my app in order for the generated methods to show up. I assume this has something to do with the fact that the built class is implementing Built<> intereface.But this seems like undesirable behavior. I expected that I should be able to use the class in my app, without needing to add built_value to the pubspec, since my app only uses the generated class code, and it does not directly use the Built<> class or anything else from the built_value package.
Am I misunderstanding something? or perhaps I did not set something up properly.