google / google/built_value.dart

`JsonObject` factory accepts null, but will throw when null is passed

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

Description

the `JsonObject` factory accepts a nullable parameter, but if null is passed it will throw
```dart
/// Instantiates with [value], which must be a bool, a List, a Map, a num
/// or a String. Otherwise, an [ArgumentError] is thrown.
factory JsonObject(Object? value) {
if (value is num) {
return NumJsonObject(value);
} else if (value is String) {
return StringJsonObject(value);
} else if (value is bool) {
return BoolJsonObject(value);
} else if (value is List) {
return ListJsonObject(value);
} else if (value is Map) {
return MapJsonObject(value);
} else if (value is Map) {
// Allow wrong type map, check individual values.
return MapJsonObject(value.cast());
} else {
throw ArgumentError.value(value, 'value',
'Must be bool, List, Map, num or String');
}
}
```

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.