Skip to content

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

@isoos

Description

@isoos

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

Map<String, dynamic> _$XyzToJson(Xyz instance) =>
    <String, dynamic>{
      '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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions