google / google/json_serializable.dart

Unnecessary use of a null check ('!') on enum values.

Open
#1,515 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Dart
Stars
1.6k
Forks
461
Avg merge
45m
Merged PRs (30d)
1

Description

Latest version (6.10.0 on Dart 3.8.0) generates the following code for an enum field

```dart
Map _$XyzToJson(Xyz instance) =>
{
'state': _$AbcEnumMap[instance.state]!,
};
```

The generated `_$AbcEnumMap` is a const map with all the enums listed, and the linter now complains that it is an unnecessary operation.

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.