google / google/json_serializable.dart
need fromJson with Type
Open
- Dominant language
- Dart
- Stars
- 1.6k
- Forks
- 461
- Avg merge
- 45m
- Merged PRs (30d)
- 1
Description
e.g. I have a nullable list ['text', null] and write a safe conversion
```
@JsonKey(fromJson: safeList)
List property;
```
```
List safeList(dynamic value, {List defaultValue = const []}) =>
safeNullableList(value) ?? defaultValue;
List? safeNullableList(dynamic value) {
if (value is List) return value;
if (value is List) return value.whereType().toList();
return null;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.