Open filiph opened 3 years ago
Hmmmm I think the right thing is that for a nested builder for a non-nullable field, the builder field should be not nullable and initialized, exactly as you ended up with at the end.
So I think fixing the error message is correct.
Will take a look when I get to the next batch of built_value
improvements :)
Thanks!
Hi there! First of all, thanks for maintaining this package. It's been a big part of my workflow for years now!
I'm afraid I hit a snag. I have a class like this:
and a custom builder class like this:
This worked just fine before null safety. After upgrading to null safety using the migration tool (naive approach?), the classes look like this:
and the builder class:
Now, the generator does not work, and spits out this error message:
It took me a while to understand that the "if applicable, builder" part means
ListBuilder<Item>?
. Then I was confused, because that's what I already have there.So I changed the code in
built_value_generator
'svalue_source_field.dart
to tell me more:And this was the output:
So, either the check is incorrect (and nullable
BuiltList<Item>?
should be permitted), or the error message should be expanded.What worked for me is this:
Now the source generation works and tests pass.