Skip to content

Add an option for jsonSerializable annotation to choose what enum property name or index to use for serialization. #1290

Open
@bambinoua

Description

@bambinoua

Now generated code contains such statement for ThemeMode enum:

const _$ThemeModeEnumMap = {
  ThemeMode.system: 'system',
  ThemeMode.light: 'light',
  ThemeMode.dark: 'dark',
};

So enum values are serialized as Strings but having a possibility to serialize enum values as integers would be a good option.

const _$ThemeModeEnumMap = {
  ThemeMode.system: 0,
  ThemeMode.light: 1,
  ThemeMode.dark: 2,
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions