google / google/built_value.dart

Auto add builder factories for nested built_collection classes

Open
#1,254 4 comments 2 reactions 1 assignee Claimed by @davidmorgan View on GitHub
p2 / feature request
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

When using BuiltMap nesting, is it not automatically created?

```
abstract class Calendar implements Built {
...
@BuiltValueField(wireName: 'calendar')
BuiltMap>>? get calendar;
...
}
```

automatically generated below
```
..addBuilderFactory(
const FullType(BuiltMap, const [
const FullType(String),
const FullType(BuiltMap, const [
const FullType(String),
const FullType(
BuiltList, const [const FullType(DayDTO)])
])
]),
() => new MapBuilder>>())
```

however, the below needs to be added manually.
```
..addBuilderFactory(
const FullType(BuiltMap, const [
const FullType(String),
const FullType(
BuiltList, const [const FullType(DayDTO)])
]),
() => new MapBuilder>())
..addBuilderFactory(
const FullType(
BuiltList, const [const FullType(DayDTO)]),
() => new ListBuilder())
```

It won't work unless you add it manually in the code above. So you have to add it manually, but it works.

Is there a way to automatically generate it?

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.