google / google/built_value.dart

`null` value isn't retained on a ListBuilder field of Builder class that is marked @nullable on Built class

Open
#1,094 1 comment 0 reactions 1 assignee Claimed by @davidmorgan View on GitHub
question
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

my code:
```dart
abstract class MyClass implements Built {
@nullable
@BuiltValueField(wireName: r'my_field')
BuiltList get myField;
}
```
is being generated to

```
class MyClassBuilder implements Builder {
ListBuilder _myField;
ListBuilder get myField =>
_$this._myField ??= new ListBuilder();
set myField(ListBuilder myField) =>
_$this._myField = myField;
}
```

When I set value of `myField` to `null`, I was expecting it to return `null` on get, but it returns empty list instead (because of how the getter above is generated)

Appreciate any help on this matter! Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.